在 Vista 上使用 C#/WIA 2.0 版进行扫描 [英] Using C#/WIA version 2.0 on Vista to Scan

查看:30
本文介绍了在 Vista 上使用 C#/WIA 2.0 版进行扫描的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想实现一个无纸化归档系统,并希望使用 WIA 和 C# 来获取图像.CodeProject 等上有不少示例项目,但是我把能找到的每一个都下载后,遇到了一个问题.

I want to implement a paperless filing system and was looking to use WIA with C# for the image acquisition. There are quite a few sample projects on CodeProject, etc. However, after downloading every one of them that I can find, I have run into a problem.

在每一个中,对 WIALib 的引用都被破坏了.当我添加Microsoft Windows Image Acquisition"作为参考时,我的开发工作站(也是将运行它的机器)上唯一可用的版本是 2.0.

In each and every one of them, the reference to WIALib is broken. When I go to add "Microsoft Windows Image Acquisition" as a reference, the only version available on my development workstation (also the machine that will run this) is 2.0.

不幸的是,这些示例项目中的每一个似乎都是针对 1.x 编码的.引用以WIA"而不是WIALib"的形式出现.我试了一下,只是改变了命名空间导入,但显然 API 完全不同.

Unfortunately, every one of these sample projects appear to have been coded against 1.x. The reference goes in as "WIA" instead of "WIALib". I took a shot, just changing the namespace import, but clearly the API is drastically different.

是否有关于实施 v2.0 或升级这些现有示例项目之一的任何信息?

Is there any information on either implementing v2.0 or on upgrading one of these existing sample projects out there?

推荐答案

要访问 WIA,您需要添加对 COM 库Microsoft Windows Image Acquisition Library v2.0"(wiaaut.dll) 的引用.添加使用 WIA;"

To access WIA, you'll need to add a reference to the COM library, "Microsoft Windows Image Acquisition Library v2.0" (wiaaut.dll). add a "using 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;

(系统绘图)

Image i = Image.FromStream(new MemoryStream((byte[])vector.get_BinaryData()));
i.Save(filename)

这是一种基本方式,适用于我的平板/文档进纸器.但是,如果您一次需要多个文档/页面,那么可能有更好的方法来做到这一点(从我所见,这一次只能处理一个图像,尽管我不完全确定).虽然它是 WIA v1 文档,但 Scott Hanselman 的 Coding4Fun 关于 WIA 的文章 确实包含有关如何为多个页面执行此操作的更多信息,我认为(我自己还没有走得更远)

Thats a basic way, works with my flatbed/doc feeder. If you need more than one document/page at a time though, there is probably a better way to do it (from what I could see, this only handles one image at a time, although I'm not entirely sure). While it is a WIA v1 doc, Scott Hanselman's Coding4Fun article on WIA does contain some more info on how to do it for multiple pages, I think (I'm yet to go further than that myself)

如果是无纸化办公系统,您可能还需要查看 MODI(Office Document Imaging)来为您完成所有 OCR.

If its for a paperless office system, you might want also check out MODI (Office Document Imaging) to do all the OCR for you.

这篇关于在 Vista 上使用 C#/WIA 2.0 版进行扫描的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆