I'm using WIA to capture an image fron the scanner to the windows form. Here is the code I'm using:
private void button2_Click(object sender, EventArgs e)
{
const string wiaFormatJPEG = "{B96B3CAE-0728-11D3-9D7B-0000F81EF32E}";
CommonDialogClass wiaDiag = new CommonDialogClass();
WIA.ImageFile wiaImage = null;
wiaImage = wiaDiag.ShowAcquireImage(
WiaDeviceType.UnspecifiedDeviceType,
WiaImageIntent.GrayscaleIntent,
WiaImageBias.MaximizeQuality,
wiaFormatJPEG, true, true, false);
WIA.Vector vector = wiaImage.FileData;
Image i = Image.FromStream(new MemoryStream((byte[])vector.get_BinaryData()));
i.Save(@"D:\prueba1.jpeg");
}
When trying to run this little test, I get this error:
Interop type 'WIA.CommonDialogClass' cannot be embedded. Use the applicable interface instead.
And this:
'WIA.CommonDialogClass' does not contain a definition for 'ShowAcquireImage' and no extension method 'ShowAcquireImage' accepting a first argument of type 'WIA.CommonDialogClass' could be found (are you missing a using directive or an assembly reference?
I'm guessing the second error is being risen because of the first error, right?
Any suggestions on how to fix this?