WIA Twain 支持 C#
如何在 C# 中使用 WIA 和 Twain? TWIAIN/C# 示例位于 http://www.codeproject.com/KB/dotnet /twaindotnet.aspx 在 TwainLib.cs 的第 59 行引发异常“尝试加载格式不正确的程序”。 在 Vista 64 上。
我会使用 WIA,但它不支持我想要使用的所有设备。
有没有一种简单的方法可以在 C# 中的 WIA 中启用 TWAIN 支持? 我知道可以做到,但我找不到有关该主题的任何文档。 我不是在寻找商业产品。 我可以很好地弄清楚如何使用 WIA - 但事实上我无法启用 TWIAN 支持,这一点很烦人。
也欢迎使用 C++/CLI 或 VB.net 的示例。
谢谢。
编辑
谢谢,克里斯蒂安利巴多。 你帮了我很多忙,我现在可能会继续使用 TWIAN。 但我还是想用WIA; 所以我还不会接受你的回答。 这里为刚刚看到这篇文章的人提供了一些更多信息。 所有人都在回应这个答案:
是的,这是为了 TWIAN 支持; 谢谢! 但我仍然想使用 WIA; 但现在我有事情要做。 但是,当我选择 USB 摄像头作为源并点击“获取”时,应用程序挂起。 我的相机适用于其他商业 TWIAN 应用程序。
通过注释掉第 100 至 104 行(检查“DScap( appid, srcds, TwDG.Control, TwDAT.Capability, TwMSG.Set, cap );”是否返回 TwRC.Success 的代码,我的相机现在可以工作了。我没有知道这段代码的作用;因为文档在这个主题上几乎没有任何内容;
它与每个会话扫描多个图像有关。
How can I use WIA and Twain in C#? The TWIAIN/C# example found at http://www.codeproject.com/KB/dotnet/twaindotnet.aspx Throws an exception at line 59 on TwainLib.cs "an attempt was made to load a program with an incorrect format." on Vista 64.
I would use WIA but it does not have support for all of the devices I want to use.
Is there a simple way to enable TWAIN support in WIA in C#? I know it can be done but I cannot find any documentation on the subject. I am not looking for a commercial product. I can figure out how to use WIA just fine - but its the fact that I cant enable TWIAN support that is annoying.
Examples in C++/CLI or VB.net are also welcome.
Thanks.
EDIT
Thanks, cristianlibardo. You helped me out a lot and I might just continue to use TWIAN for now. But I am still wanting to use WIA; so I will not accept your answer yet. Here is some more info for people just seeing this post. All are in response to this answer:
Yup, that did it for the TWIAN support; thanks! I still want to use WIA though; but now I have something to work with. However, when I select my USB camera as the source and hit acquire, the app hangs. My camera works on other, commercial, TWIAN applications.
By commenting out the lines 100 though 104 (code that checks to see if "DScap( appid, srcds, TwDG.Control, TwDAT.Capability, TwMSG.Set, cap );" returns TwRC.Success my Camera now works. I have no idea what this code does; as documentation is next-to-nothing on this subject.
OK; its a const called "CAP_XFERCOUNT" that has something to do with scanning multiple images per session. Makes seance that a camera would not support it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
可能可能性不大,但您是否尝试过使用 x86 作为平台目标进行构建或更改线程单元状态?
Probably a long shot but have your tried building with x86 as platform target or changing thread apartment state?