要訪問WIA,您需要添加對COM庫「Microsoft Windows Image Acquisition Library v2.0」(wiaaut.dll)的引用。 添加「使用WIA;」
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;
(System.Drawing中)
Image i = Image.FromStream(new MemoryStream((byte[])vector.get_BinaryData()));
i.Save(filename)
這就是一個基本方式,可與我的平板/文檔進紙。如果你一次只需要一個以上的文檔/頁面,那麼可能有更好的方法來做到這一點(從我所能看到的情況來看,這隻能處理一張圖片,儘管我不完全確定)。雖然它是WIA v1文檔,但Scott Hanselman的Coding4Fun article on WIA確實包含了一些關於如何爲多個頁面執行此操作的更多信息,我認爲(我還沒有比我自己更進一步)
如果它適用於無紙辦公系統,您可能還需要查看MODI(Office Document Imaging)爲您執行所有OCR。
快速的問題。你絕對需要WIA嗎?或者你可以和吐溫一起過嗎?如果吐溫還好,我可能會有一些代碼要捐獻。 – 2008-08-12 15:48:18