can some tell me how to get a preview image of the last taken picture from my camera with WIA?
This is all you need to take a picture:
//select device
WIA.CommonDialog dialog = new WIA.CommonDialog();
WIA.Device camera = dialog.ShowSelectDevice(WIA.WiaDeviceType.CameraDeviceType, false, true);
//take picture
camera.ExecuteCommand("{AF933CAC-ACAD-11D2-A093-00C04F72DC3C}");
with this I can get all camera properties, but there is no last picture info:
string p = "";
foreach (Property p in camera.Properties)
{
p += p.Name + ":\t" + p.get_Value() + "\n";
}
MessageBox.Show(p);
ExecuteCommand returns a WIA.Item which provide a Transfer method :
WIA.CommonDialog dialog = new WIA.CommonDialog();
WIA.Device camera = dialog.ShowSelectDevice(WIA.WiaDeviceType.CameraDeviceType, false, true);
WIA.Item takenItem = camera.ExecuteCommand("{AF933CAC-ACAD-11D2-A093-00C04F72DC3C}");
foreach (string formatId in takenItem.Formats)
{
if (Guid.Parse(formatId) == System.Drawing.Imaging.ImageFormat.Jpeg.Guid)
{
WIA.ImageFile wiaImage = takenItem.Transfer(formatId);
var imageData = new MemoryStream( wiaImage.FileData.get_BinaryData());
var image = Image.FromStream(imageData);
//pictureBox1.Image = image;
}
}