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

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

问题描述

我想实现无纸化备案制度,并一直在寻找使用威​​亚用C#进行图像采集。也有相当的$ C $的CProject等几样的项目然而,下载他们每个人,我可以找到后,我遇到了一个问题。

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被打破了。当我去加上微软Windows图像采集为基准,唯一可用的版本,我的开发工作站上(也是机器将运行这个)是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的codeD参考进去的威亚,而不是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.

是否有一个实现2.0版或升级现有的这些示例项目在那里?

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

推荐答案

要访问WIA,你需要添加一个引用到COM库,微软Windows图像采集库2.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;

(System.Drawing中)

(System.Drawing)

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

这就是一个基本的方法,可以与我的平板/文档进纸器。如果你需要一个以上的文件/页面的时间,虽然,有可能是一个更好的方式来做到这一点(从我所能看到的,这个只处理一个图像的时间,虽然我不是很确定)。虽然这是一个WIA V1的文档,对WIA斯科特Hanselman的的Coding4Fun文章确实包含如何做到这一点对多页,我想一些更多的信息(我还没有更进一步比我自己)

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)

如果其无纸化办公系统,你可能也想看看莫迪(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天全站免登陆