Forum Replies Created
- AuthorPosts
Hi Susanna, thanks for spamming our forum.
I bet this really helps the reputation of RasterEdge with imaging professionals.
Of course, we are talking about a company that doesn’t have a phone number 8)Hi yns.emre
The answer in a general way remains “no”. TWAIN drivers often display a modal dialog when they encounter certain conditions. In general this is not prohibited by the TWAIN standard, so it is common but (like every TWAIN thing) the details vary from driver to driver. Even when the application disables the scanner User Interface (with ShowUI=FALSE), there is a strong chance the driver still creates its main window, just keeping it hidden.
So I wonder: If you don’t allow the first TWAIN application to run, does your service work, when it does not have to ‘share’ the scanner?
I am concerned because TWAIN generally does not work in a service, especially if desktop interaction is disabled: TWAIN drivers assume that they can create windows and interact with the user, and there is no way to stop them from doing this.
Well 8) it’s Windows, so nothing is impossible – but you’d have to hook/intercept calls to the common Windows API functions like DialogBox. At least. Probably very messy.
What I’ve seen people do (e.g. EMC Captiva’s Web Scanning Toolkit) is this: They run a service, and when the service is asked to do scanning, it launches an .exe as a separate process. I guess they launch the scan process as belonging to the user who submitted the request to the service?
1- The first application (other application-does not matter) opens the twain data source and shows the driver graphical user interface
2- At this time, a scan request is sent from network to our application(second application). We are using the TwainDSM. There is no problem until we sent MSG_OPENDS message,
But when we sent MSG_OPENDS message, our application thread hangs and wait forever.
My question is :
– How to solve this hanging problem ?
– Is it possible to understand that the twain driver is currently used by an another application and is not suitable for sending the MSG_OPENDS message ?There is no TWAIN mechanism for asking if a driver or device is busy, the TWAIN device driver is responsible for detecting this situation and responding appropriately.
1. Check that your application is correctly checking the return code from the MSG_OPENDS, so if the driver is failing the 2nd open, your code would handle that correctly. I would expect a properly coded driver to return TWRC_FAILURE, and then report a Condition Code of TWCC_MAXCONNECTIONS (“The data source cannot support any more connections to this device”).
2. If your application is correctly coded and the driver is hanging inside the MSG_OPENDS call, then this is a driver problem, and you should discuss this with the scanner vendor.
January 22, 2014 at 8:26 pm in reply to: Set ICAP_Contrast by coding with hide user interface dialog #26057Hi xostar1 – So: the error happens every time, on the 2nd scan, with three different Kodak scanners?
Maybe the problem is not with ICAP_CONTRAST, but something is in the wrong state after the 1st scan.It is very odd though, because that is such a specific error report. It is not the error I would expect if the driver was not open, or was in state 5,6 or 7.
Do you close the scanner after the first scan?
Each time you set ICAP_CONTRAST, do you set ICAP_PIXELTYPE first?What code or library are you using to control the scanner?
Gee xiaoyuandlg, thanks for the subtle spam, you’re really making the world a better place.
January 21, 2014 at 4:38 pm in reply to: Set ICAP_Contrast by coding with hide user interface dialog #26055Hi xostar1 – can you tell if that error is happening specifically when the code tries to set ICAP_CONTRAST?
If so, maybe your scanner doesn’t support ICAP_CONTRAST – that would be odd, but after all it isn’t a required capability.
What scanner are you testing with?
“the bmp in Imagemagick is different from the bmp image format that we commonly used, right”
what? why would that be?“Or the Imagemagic just owns the capacity to convert bmp image file to PDF pages?”
Yes. Google is your friend here. For example:
http://stackoverflow.com/questions/9706046/imagemagick-convert-multiple-images-to-pdf-sizeNovember 26, 2013 at 5:29 pm in reply to: Twain Application, Windows C#, Callbacks & Win Message Loop #25925Very belatedly, in the hope it is useful to somebody else:
You still have to intercept the Windows message pump and route messages to TWAIN, even if you use TWAIN 2.0 callbacks to handle events from TWAIN.
Guess I should mention that one way to do that is to run your own message pump, but that does get kind of tricky, and is best done on a dedicated thread.
For those working in .NET/Mono, Mark has published a comprehensive TWAIN wrapper called TWAIN for C-Sharp (C#) on SourceForge, with two sample applications:
http://sourceforge.net/projects/twainforcsharp/?source=directoryNovember 15, 2013 at 9:08 pm in reply to: Scanned Image came out "side ways" (see attached image) #26028The ByesPerRow is always set to 3435973836
So that’s 0xCCCCCCCC – which is the value Visual C/C++ puts in uninitialized variables in a debug build.
I’m guessing the TWAIN driver isn’t a debug build 😉 so probably your application is a debug build? That would explain how that structure member gets set to that value, and apparently the TWAIN driver never updates it, and that would be kind of a bug…Except this is an up-to-date Fujitsu driver, so I’m skeptical that it’s a driver bug.
Do all the other values in the TW_IMAGEMEMXFER look reasonable after the call to DG_IMAGE/DAT_IMAGEMEMXFER/MSG_GET?I wouldn’t worry much about the resolution, until you are calculating the bytes-per-row correctly. It’s easy for row-alignment to be accidentally right at some resolutions and wrong on others. How *are* you calculating bytes per row, if the BytesPerRow from the driver seems to be garbage?
November 12, 2013 at 6:06 pm in reply to: Scanned Image came out "side ways" (see attached image) #26026I forgot something: You need to pay attention to the BytesPerRow member of the TW_IMAGEMEMXFER structure.
You can’t assume that each row of pixels is just the minimum number of bytes – it might be padded, for example, the way ‘DIB’ rows are padded to 4-byte boundaries.November 12, 2013 at 5:49 pm in reply to: Scanned Image came out "side ways" (see attached image) #26025Hi yuyan – that definitely looks like the width of the image, in either pixels or bytes, is not being determined correctly.
1. I hope you aren’t using floats or FIX32 values to compute the width of the image data – that is unlikely to work well.
The width, in pixels, of the image is available either:
a) by doing a DG_IMAGE/DAT_IMAGEINFO/MSG_GET after the DAT_SETUPMEMXFER/MSG_GET
and looking at info.ImageWidth … or …
b) by looking at the ‘Columns’ value in the first TW_IMAGEMEMXFER structure you get from doing DG_IMAGE/DAT_IMAGEMEMXFER/MSG_GET2. That FloatToFix32 function is the one the TWAIN driver should be using, it isn’t very useful in your application code. And it correctly converts the value 8.5 to the integer 557056, which is 0x88000 – so, 8 in the Whole part, and 0x8000 (32768) in the Frac part. So it seems to me the TWAIN driver is encoding 8.5 correctly, so I wonder if your function to convert back Fix32ToFloat, is not correct? In a FIX32, the ‘Frac’ part is not the decimal fraction of the number: to represent 8.5, Frac is not 5, it’s the 16-bit binary fractional part: 32768.
Hope this helps, happy to answer questions.
The Select Source dialog can set the default TWAIN device because that dialog is owned and displayed by the TWAIN Manager, so it has access to internal functions of the manager (that you don’t have access to).
Can I ask (again) why you think you need to do this?
The default TWAIN device is a *user-wide* setting, affecting all applications. If you are trying to set that, you are taking on some of the function of the TWAIN manager, so your application should be some kind of ‘TWAIN management utility’ or ‘Scanner management utility’. And even then, why not just display the standard Select Source dialog?If your application just scans (like many other applications) then it has no business changing the default TWAIN device for all other scanning applications.
If you just need a way for the user of your application to select the scanner *your application* will use, then show the user the list of TWAIN devices, let him or her pick, and then store the name of the selected scanner as part of the configuration of your application, and then scan from that scanner.
Are you trying to fool some other application into scanning from a scanner that your application selects?
“Accidents are not accidents but precise arrivals at the wrong right time.”
― Dejan StojanovicI post this only so this thread goes off the 0 replies list 8)
It sounds like your problem is solved, and I am glad to hear that!
However, I would certainly like to know what exactly was broken that was fixed by updating (updating, yes?) your twain.h file. 8)
If you have any ideas or observations, please share them here!First, CAP_UICONTROLLABLE is a read-only value. TRUE means the driver is willing and able to suppress its UI (at the request of an application).
FALSE (which I’ve never seen and is strongly discouraged by the TWAIN standard) would mean the driver always shows the same UI (or lack of UI?), ignoring what the application requests.Second, the settings you see in the sample app are not persistent configuration settings. The TWAIN standard doesn’t require any of them to be remembered after you close the device, although some drivers will remember some settings.
‘show your user interface’ is NOT a TWAIN setting like CAP_UICONTROLLABLE. The only place in the TWAIN standard where there is control over showing the scanner UI is in the MSG_ENABLEDS message – which is the command to the scanner driver that means ‘show-your-UI-or-start-scanning’.
That command has a parameter that means show (or don’t show) the scanner UI. It is sent from the application to the driver, and it applies only at that time.Sorry. I think the Window ‘auto-button-click’ hack is still the best solution I can think of.
- AuthorPosts