Forum Replies Created
- AuthorPosts
@kaiserovich wrote:
Twain doesnt support Linux OS…
The TWAIN protocol and Data Source Manager are supported on Linux. What’s missing is apps and drivers, though some do exist (e.g. https://www.google.com/#q=kodak+scantwain)
It’s a chicken and egg situation. There are so few TWAIN drivers available on Linux that app developers see little use for it. Likewise, since there are so few TWAIN apps, hardware vendors usually won’t bother to create a driver.
As you’ve discovered, SANE is to Linux as TWAIN is to Windows.
–Glad to hear you got it working. As an added bonus, now your main application will not crash due to a buggy TWAIN driver.
–There is no way to load 32-bit TWAIN drivers in a 64-bit application. You might consider creating a separate 32-bit application to run the TWAIN drivers and have it send the images to your 64-bit application.
–As you found, there are very few 64-bit TWAIN drivers. You just need to specify “x86” instead of “AnyCPU” to force your app to run in 32-bit mode on a 64-bit OS. Maybe a .NET expert would be willing to explain if there is any downside to doing this.
–@spike wrote:
What would you TWAIN experts – and driver writers 😉 – recommend as best practice for an application that wants to scan a custom (non-standard) sized piece of paper?
Hi Spike,
You should use DAT_IMAGELAYOUT not ICAP_SUPPORTEDSIZES to set a custom scan area. All DS’s are required to support DAT_IMAGELAYOUT.
Note that scanners with feeders may require special consideration. ICAP_SUPPORTEDSIZES takes care of the feeder alignment but DAT_IMAGELAYOUT does not. This is not an issue if you always scan the full width. Otherwise, you’ll need to read CAP_FEEDERALIGNMENT and align the scan area accordingly.
Doug
–Hi Daiana,
That’s interesting. I did some digging. Here’s what I’ve found.
TWAIN spec 2.1 says:
While the Source’s user interface is raised, the Source is responsible for presenting the user with appropriate progress indicators regarding the acquisition and transfer processes unless the application has set CAP_INDICATORS to FALSE. The Source must also report errors to the user (without regard for the settings of CAP_INDICATORS and ShowUI, i.e. they may be set to FALSE and errors still must be reported)
My emphasis added.
I was going on that information but, as you pointed out, spec 2.2 says:
If the Source user interface is not displayed, and the Application sets CAP_INDICATORS to FALSE, then the Source is not allowed to display any kind of user interface, progress indicator or error dialog. All UI activity must be suppressed.
This very recent change to the spec makes your original question a good one. In the case of an empty feeder, it looks like MSG_ENABLEDS should return TWRC_FAILURE/TWCC_NOMEDIA. But what if showUI is FALSE, CAP_INDICATORS is FALSE, and some other device error occurs? Perhaps return TWRC_FAILURE/TWCC_OPERATIONERROR even though the DS did not handle the error.
That’s my interpretation of the spec. Anyone else care to weigh in on this?
—Hi xdaiana,
If you are developing a DS, it’s best to prompt the user to load the feeder. Then start the scan if they click “OK” with paper loaded or return an error if they click “Cancel”. CAP_INDICATORS only controls progress indicators; it is not relevant in this situation. Please see the section in the specification titled “Error and Device Control Indicators”.
If you are developing an application and would prefer to avoid this situation, check CAP_FEEDERLOADED before enabling the DS.
—Try this: TWAIN sample Data Source and Application
@adrien.nguyen wrote:
The twain toolkit with fake source is no longer available. Any other solutions ?
Even when an application sets ShowUI to false on MSG_ENABLEDS and CAP_INDICATORS to false, the DS may show UI. To see how it can do that while still be compliant with the specification, please read the section “Error and Device Control Indicators” in the TWAIN specification.
If that’s not a show stopper your webserver should create an window (as spike suggested) or call GetDesktopWindow() to get a valid HWND to use as the parent window. Note that if the webserver is a Windows service it should not call TWAIN since it may need to display UI.
@theck01 wrote:
Hi everyone,
I’m currently writing an application that interfaces with a Leica microscopy camera on Windows XP, and things have been going smoothly so far. The application is a simple web server that allows the microscope to be controlled from a different location. Because the application is a web server I have been preventing the TWAIN session from opening any windows and have set the hParent field of TW_USERINTERFACE to NULL when enabling the data source. The webserver has no window of its own, so there is nothing that I can set hParent to that will make sense.
Things work well until I attempt to shut the server down. At this point the data source cannot be disabled, and neither the data source or the data source manager can be closed successfully. From my experimentation I believe that this is due to the NULL value I gave to the hParent field of TW_USERINTERFACE. Is there a value that I should be giving the hParent field besides NULL for a windowless application? And does anyone have other ideas about why the source and source manager refuse to close, even if all I do is start open them, enable the source, and then immediately attempt to disable and close?
Thanks
In the past, Apple provide sample code for a TWAIN app and a DS in their Dev Center. Now there’s no useful information there.
It seems Apple is pushing developers to switch to ICA drivers. 10.7 does include the TWAIN framework (with a Mac-specific TWAIN.h file) but the way it’s going that may disappear soon.
–@Vankir wrote:
Can data source return several TW_IDENTITY to let DSM show several models in the list of data sources?
For example I have superdriver.ds and would like to present several scanners in select data source dailog like following…TWAIN does not support that.
Your best bet is to do what scanner vendors do when providing a single DS to support many models. They return a somewhat generic name (e.g. “ScanWizard”) in the identity struct and then provide UI when their DS is enabled to allow the user to select a specific scanner.
–I didn’t intend to be harsh. Glad to help.
@keniff1 wrote:
Hi, i´m trying to scan in landscape but it doesn´t work….
You’re using the wrong triplet. ICAP_ORIENTATION is a capability so it’s set by DG_CONTROL / DAT_CAPABILITY / MSG_SET not DG_IMAGE / DAT_IMAGELAYOUT / MSG_SET.
If you haven’t already, it would be good to spend some time reading the “Application Implementation” chapter in the TWAIN specification.
–April 15, 2011 at 4:27 pm in reply to: How to activate the scanner without using the driver GUI #25427@VBCoder68 wrote:
…how do you start the scanner without having to display the driver window to the user? Thanks, Mike
The TWAIN specification has a detailed answer to your question. Take a look at the section titled “Alternatives to Using the Source’s User Interface” In chapter 4.
You’ll need to become familiar with the specification in order to use advanced features like suppressing the UI. There is a lot of good information in there. Also, be sure to go over the FAQ http://twain.org/faqs.shtm for some of the more common questions. Then, if you’re still stuck post a question and we’ll see if we can help.
Good luck.
–Wow, a 4+ year-old thread revived.
The TWAIN spec doesn’t seem to cover reentrancy or multithreading. Note that messages may be posted to the wrong message queue if TWAIN is called from a thread other than the one which owns its window. This can result in unresponsive UI or deadlocks (e.g. XFERREADY is never received). For maximum compatibility a process should make all TWAIN calls from a single thread: the one that owns the parent window provided to TWAIN. The thread that calls TWAIN does not have to be the app’s main UI thread; it can be a worker thread with it’s own message loop.
–- AuthorPosts