在 Vista 上使用 C#/WIA 2.0 版进行扫描

发布于 2024-07-04 04:10:12 字数 359 浏览 13 评论 0原文

我想要实现一个无纸化归档系统,并希望使用 WIA 和 C# 来采集图像。 CodeProject 等上有很多示例项目。但是,在下载了我能找到的每一个示例项目后,我遇到了问题。

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

不幸的是,这些示例项目中的每一个似乎都是针对 1.x 进行编码的。 该引用作为“WIA”而不是“WIALib”。 我尝试了一下,只是更改了名称空间导入,但显然 API 截然不同。

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

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.

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.

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.

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

夏九 2024-07-11 04:10:12

要访问 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 的 关于 WIA 的 Coding4Fun 文章< /a> 确实包含一些有关如何对多个页面执行此操作的更多信息,我认为(我自己还没有走得更远)

如果它用于无纸化办公系统,您可能还需要查看 MODI(Office Document Imaging) )为您完成所有 OCR 操作。

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)

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

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)

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

素罗衫 2024-07-11 04:10:12

这里还介绍了如何以 WIA 1.0 为目标,以便您可以将应用程序发送到 Windows Xp。 我拼命寻找的东西!
如何在 Vista 下使用 WIA 1 进行开发?

Heres how to target WIA 1.0 also so you can ship your app to Windows Xp. Something I was desperately looking for!!
How to develop using WIA 1 under Vista?

玩套路吗 2024-07-11 04:10:12

不需要是WIA。 我主要关注 WIA 设置,因为它为不同的扫描仪提供相同的基本界面。 我的这台机器上有 3 个扫描仪,所有扫描仪的 TWAIN 驱动程序/软件都很糟糕(比如在扫描过程中挡住屏幕)。

对于文档管理,我确实在寻找简单的 200dpi 灰度扫描,因此 TWAIN 驱动程序中的大部分内容都是多余的。

也就是说,在转向 TWAIN 之前,我最后一次尝试弄清楚如何在 WIA 中做到这一点,在此询问是我的一部分。

It doesn't need to be WIA. I was mostly looking at the WIA setup because it offers the same basic interface for different scanners. I've got 3 scanners on this machine and the TWAIN drivers/software for all of them suck (like blocking the screen during scanning).

For document management, I'm really looking for simple 200dpi grayscale scans, so most of the stuff in the TWAIN drivers is overkill.

That said, asking here was part of my last attempt to figure out how to do it in WIA before moving on to TWAIN.

很酷又爱笑 2024-07-11 04:10:12

更新:我单独添加这个,因为它是一个不同的答案(一年后)。 我了解到XP有WIA 1.0,Vista及以上版本有WIA2.0。 不过,您可以从此处安装适用于 Windows XP Sp1+ 的 WIA 2.0。

然后我还用我在互联网上找到的代码制作了一个小型库,它还具有扫描多个页面的能力:
http://adfwia.codeplex.com/

Update: I'm adding this separately since its a different answer (a year later). I learnt XP has WIA 1.0 and Vista onward has WIA2.0. You can however install WIA 2.0 for Windows XP Sp1+ from here.

I then also made a small library with code I found somewhere on the interweb here, it also has the ability to scan multiple pages:
http://adfwia.codeplex.com/

抱着落日 2024-07-11 04:10:12

另请注意:您必须从 Microsoft.com 下载 WIA 2.0 dll,然后浏览到该 dll 并将其添加到您的项目中。

Another note: You have to download the WIA 2.0 dll from Microsoft.com and then browse to the dll and add it to your project.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文