跨平台扫描库

发布于 2024-10-13 10:45:58 字数 1180 浏览 7 评论 0原文

很长一段时间以来,您需要特殊的软件来从平板扫描仪创建多页 PDF 文档,这让我很恼火。因为“扫描仪”是一个模棱两可的词(这确实使搜索变得困难!)让我澄清一下:我的意思是,例如,HP F4280 打印机/扫描仪设备以光学方式“扫描”纸质文档并创建以下内容的数字表示的过程:它通常以 .jpg 或 .tif 文件结束。

问题是,据我所知,没有任何程序是跨平台的,并且能够从平板扫描仪创建多页扫描件。为此,软件必须一次存储每个扫描的页面,并询问用户是否要扫描另一页面。您不能依赖驱动程序来处理多页扫描,因为驱动程序仅对换页扫描仪执行此操作,这些扫描仪将不间断地“吸入”一叠纸,并在将数据传递给驱动程序框架之前合并数据。

因此,我开始踏上创建这样一个程序的道路。在底层,我想在 Windows XP 或更高版本、Mac OS X 以及流行的 Linux 2.6 发行版上支持 TWAIN 和 SANE 接口。 2008年或之后的年份。

这是我设想的运作方式。首先,我需要一个提供统一 API 的库,无论后端使用 TWAIN 还是 SANE。 API 必须能够提供扫描数据的压缩或其他位的字节数组。 TWAIN 和 SANE 之间共享的一些属性应该公开:例如,DPI、纸张尺寸和颜色/灰度/线条。然后应该可以显式指定、提示或查询成功扫描返回的字节数组的结果图像格式。

我并不特别关心编程环境:我熟悉所有流行的命令式/OO 语言。我更喜欢 Java 或 C# 之类的东西,但 C 或 C++ 也可以很好地工作。

一旦我手头有了这样的库,我就可以构建一个 GUI,只需根据需要调用例程,并使用几个可用的 PDF 渲染库之一来创建输出。我不坚持“编译一次,到处运行”,但我至少坚持“编写一次,到处编译”。当然,由于 TWAIN 和 SANE 是在互斥平台上可用的不同 API,因此在某些时候必须有一些 #ifdef 或其他区分平台的方法来确定使用哪个 API。

我打算让我的程序和我直接链接的任何库都有资格成为自由软件(根据 FSF),但我对编程环境的唯一要求是它在 Windows XP 或更高版本、Mac OS X 和Linux 2.6。

我一直在谷歌上搜索很多东西来找到这样一个库,但我什至找不到一个专有的库,更不用说免费软件了。如果有人找到了这样的宝石,请给我提供一个链接——否则,任何关于开始使用我的应用程序的建议将不胜感激。如果有必要,我将自己开发上述库,并将其作为 GNU LGPL 下的单独项目发布。就应用程序而言,我更愿意用 Qt4/C++、.NET with GTK# 或 Java/Swing 编写它,以获得最大的跨平台兼容性。

For a long time, it has annoyed me that you need special software for creating a multi-page PDF document from a flatbed scanner. Because "scanner" is an ambiguous word (which REALLY makes searching difficult!) let me clarify: I mean, for example, the process by which an HP F4280 printer/scanner device optically "scans" a paper document and creates a digital representation of it, usually ending up as a a .jpg or .tif file.

The problem is that I know of no program that is cross-platform, and capable of creating multi-page scans from a flatbed scanner. To do this, the software has to store each scanned page, one at a time, and ask the user if they want to scan another page. You cannot rely on the driver to handle multi-page scanning, because drivers only do that for form feed scanners that will "suck in" a stack of paper without pause, and combine the data before handing it off to the driver framework.

I am therefore starting on the road to creating such a program. At the low level, I want to support the TWAIN and SANE interfaces, on Windows XP or later, Mac OS X, and popular Linux 2.6 distros of approx. 2008 or later vintage.

Here is how I envision it will work. First, I need a library that provides a uniform API regardless of whether it is using TWAIN or SANE on the backend. The API must be able to provide a byte array of the bits, compressed or otherwise, of the scanned data. A few properties that are shared between TWAIN and SANE should be exposed: for example, the DPI, paper size, and color/grayscale/lineart. Then it should be possible to either specify explicitly, hint, or query the resulting image format of the byte array that is returned from a successful scan.

I'm not particularly concerned with the programming environment: I am familiar with all the popular imperative/OO languages. I'd prefer something like Java or C#, but C or C++ would work fine too.

Once I have such a library in hand, I can construct a GUI that just calls the routines as needed, and use one of several available PDF rendering libraries to create the output. I don't insist on "compile once, run anywhere", but I do insist on "write once, compile anywhere" at the least. Of course, because TWAIN and SANE are different APIs that are available on mutually-exclusive platforms, there will have to be at some point some #ifdefs or other method of distinguishing between platforms to determine which API to use.

I intend for my program and any libraries I directly link against to qualify as Free Software (per the FSF), but the only requirement I have of the programming environment is that it is available equivalently on Windows XP or later, Mac OS X, and Linux 2.6.

I've been googling quite a lot to find such a library, but I can't even find a proprietary one, let alone a free software one. If anyone has found such a gem, please provide me a link -- otherwise, any advice on getting started with my application would be appreciated. If necessary, I will do the development of the above-mentioned library myself, and release it as a separate project under the GNU LGPL. For the application's sake, I'd prefer to write it in Qt4/C++, .NET with GTK#, or Java/Swing, for maximum cross platform compatibility.

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

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

发布评论

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

评论(2

醉生梦死 2024-10-20 10:45:58

我知道我迟到了 8 年,但最后,我可以给你一个似乎符合你要求的库: Libinsane :-)。它支持 Sane、WIA2 和 TWAIN。您将需要 MSYS2 在 Windows 上构建它。

我为我的个人项目编写了它: 文书工作

I know I'm late by 8 years, but at last, I can give you a library that seems to match your requirements: Libinsane :-). It supports Sane, WIA2 and TWAIN. You will need MSYS2 to build it on Windows.

I wrote it for a personal project of mine: Paperwork

漫漫岁月 2024-10-20 10:45:58

不幸的是,TWAIN 是一个受到严格限制的标准。大多数制造商仅实现足够的 TWAIN 功能来运行自己的 GUI。尝试使用较低级别的 TWAIN 功能和您自己的 GUI 并不是一个实用的解决方案,除非您确实针对特定的扫描仪。

Unfortunatly, TWAIN is a severely limited standard. Most manufacturers implement only enough TWAIN functionality to run their own GUI. Trying to use lower level TWAIN functionality and your own GUI is not a practical solution unless you are really targeting a particular scanner.

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