views:

69

answers:

2

I'm currently working on a project where we want to interface with TWAIN scanners on both the PC (Windows) and the Macintosh.

On Windows, we basically have everything squared away and the code works successfully with the vast majority of scanners.

On Mac OS X, we also basically have everything working and with the main scanner we used to develop the application with works perfectly, but we're not having a ton of luck with other scanners. As a byproduct of development on this project, we have a fair number of scanners from various manufacturers on-hand to test with. The results vary wildly:

  • The scanner we used to develop with works perfectly on Mac OS X as it does in Windows. Ironically this scanner is the cheapest and crappiest scanner (speed-wise) we've ever encountered but it's been a dream to work with.
  • Another scanner works great - until the second or third scan, at which point the application crashes with no clear indication of what happened (we get an EXEC_BAD_ACCESS from the debugger)
  • Another scanner apparently has no TWAIN support on Mac OS X (no data sources in the "Image Capture/TWAIN Data Sources" folder), although it does have TWAIN support in Windows.
  • Another scanner has a generic data source that I'm thinking is supposed to cover all the possible scanners from this manufacturer but when we try to initiate a native scan (which is a requirement for all TWAIN data sources) we get no results. Also, trying to install a second scanner from this manufacturer gums everything up and requires a manual uninstall for everything from this company.
  • Another scanner has a TWAIN data source that appears to be specific to the manufacturer, but it also fails to initiate a native scan (but a scan using the native GUI - which is incompatible with our project - works)

So I'm not sure where to go with this. I'm still digging into the code to figure out what, if anything, we're doing wrong but in checking against the TWAIN standard it really does look like we're doing everything right, but we're getting very hit-or-miss results on most of the scanners we're testing against.

Also, as part of the new Cocoa/Carbon Events model there's this additional consideration of a "callback" function that Mac OS X TWAIN data sources are supposed to implement and I'm not seeing it called from most of these data source/drivers.

So all of this leads me to wonder - is it that we're just doing something wrong or is TWAIN just not supported properly by and large on the Macintosh?

I'm really not seeing a lot of information on TWAIN on the Macintosh online - the occasional sporadic inquiry on twainforum.org tends to go unanswered. Windows also has a thing called WIA - Windows Image Acquisition - and on the Windows side we also include this as an option. Is there something else on the Mac we should be exploring instead of or in addition to TWAIN?

+1  A: 

I haven't tried this, but have you checked out the image capture APIs?

http://developer.apple.com/library/mac/documentation/GraphicsImaging/Reference/ImageCaptureServicesRef/ICAApplication_h/index.html

Amorya
In Leopard, that API was terribly buggy. If the questioner can require Snow Leopard, the new scanning and downloading-from-camera APIs in Image Kit and the new Image Capture Core framework (recommended by Kiran in his answer) are much better ways. The former is high-level; the latter is lower-level.
Peter Hosey
+2  A: 

You can try ImageCaptureCore.framework. But you have to verify that the company/model scanners to which you are giving solution have ImageCapture support. If any vendor has given support then a ImageCapture module will be present in location '/Library/Image Capture/Devices'. You can also check the plists inside modules for supported models.

Hope it helps :-)

Kiran
Documentation: http://developer.apple.com/mac/library/documentation/Carbon/Conceptual/ImageCaptureServicesProgrammingGuide/
Peter Hosey