私はWIAを使用してスキャナからWindowsフォームに画像をキャプチャしています。ここで私が使用しているコードは次のとおりです。クラスを埋め込むことはできません。該当するインターフェースを代わりに使用してください
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");
}
この小さなテストを実行しようとすると、私はこのエラーを取得:
Interop type 'WIA.CommonDialogClass' cannot be embedded. Use the applicable interface instead.
そして、この:
'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?
私は推測しています最初のエラーのために2番目のエラーが発生しています。
これを修正する方法の提案はありますか?
私は、CommonDialogClassが.NET 3.5で動作し、発生している問題がそれ以降のバージョンで導入されていることがわかりました。 –