by Jim
Oct 30, 2006 10:28 PM
I got a webcam, and of course I had to access it with some .NET code. I probably could have found a program to upload images to the website, but that wouldn't have been any fun.
I found a great little library on Nauman Leghari's Blog that got me most of the way there. It gave me a video window, but needed one more function to capture a still image from the webcam:
/// <summary>
/// Capture a still image and return it
/// </summary>
/// <returns>A Bitmap image</returns>
public System.Drawing.Image CaptureStillImage()
{
System.Drawing.Image img = null;
// Tell the device to grab a frame to the clipboard
int rslt = SendMessage(deviceHandle, WM_CAP_EDIT_COPY, 0, 0);
// Look for the data on the clipboard
IDataObject iData = Clipboard.GetDataObject();
if (iData.GetDataPresent(DataFormats.Bitmap))
{
img = (System.Drawing.Bitmap)iData.GetData(DataFormats.Bitmap);
}
return img;
}