Forum Replies Created
- AuthorPosts
check that the port number through which your app is contacting the remote scanner is opened. If not, contact your VPN admin and ask him to open that port. Hope this helps. A.
A little note about duplex scanning: since my beginnings I have always been using simplex scanners to get both sides of the documents. In every application that I have programmed, my software first asks for the first pass (all front sides of the pile of documents). At the end of the first pass the operator is asked to reinsert the pile of sheets in the ADF, and then the application makes a second pass to scan the back side of the sheets.
Then the application makes the following software operations:
a) makes sure that the number of sheets in both passes are the same
b) numbers the output TIFF files in the correct order (this is necessary, of course, because during the second pass the sheets are scanned in reverse order, plus it is necessary to anternate one front and one back according to odd and even pages).
In normal office activity, a secretary deals with both sided documents in a minority of cases. This is why my approach works fine for my customers.
My trick cuts hardware costs quite a lot. (Also in the early ’90s duplex scanners were difficult to find and very expensive.)
Why give so much money to the scanner manufacturers when you can have your customers saving on hardware, and shifting that saving into your earnings ?
So I never worried about programming duplex scanners… and this is my suggestion for everyone !
For other useful software tricks about scanning documents have a look at http://www.gentle.it/alvise/ffsplitad.htm and http://www.gentle.it/alvise/ffsplitbc.htm (there is a sketch linked in the “specification” section of these web pages that explains it well).
Regards. Alvise.
Hi Gabe. Yesterday I received the Kodak i1210 scanner, I’ve installed it, and now I finally can scan a page and get the bitmap.
But the fact is that the image is mirrored both vertically and horizontally (plus black and white pixels are swapped, but this is less important).
Is there anything that I am missing ? Should I write a routine to reverse the image upside down, left to right, and to get the proper pixel colors ? Why doesnt’ the scanner provide the correct image straight out of the scan ?
Thanks. Alvise.
see TWAIN 1.9a Specification page 2-22
Alvise.
The return value from the twain entry point (nCRet) is zero (TWRC_SUCCESS) when the call has been successful. A return value above zero means failure: check the twain status to know what happened.
You should change “if (nCRet)” into “if (!nCRet)” for your code to be OK.
And you’ll discover that the call has gone wrong, but you think it was OK, and the parameter list that you read is not the real one.
Good luck with twain. Alvise.
Toolkit sample ? I didn’t notice it. Today I’ll re-inspect the package.
Thanks for the hint. Alvise.
I am not in possess of any MicroSoft compiler. But even if I had, I’d not used it because I need to integrate the resulting code into my old DLL (that I have also published for free at http://www.gentle.it/alvise/fflibdll.htm).
Yesterday I happened to download the AIIM MS61 API specification (used to implement ISIS applications) and it looks ways more simple than twain.
But I scraped my PC and couldn’t find any system DLL which impements that API, even after installing the ISIS driver of my scanner.
If I could find such a DLL I could give it a try.
Regards. Alvise.
I think you’re right. I am now developing in assembly with MASM32. But I have been programming in C++ with the Borland compiler for a decade and never got into major troubles.
Regards. Alvise.
Hi Gabe:
>> try the same code on the same hardware
>> same drivers with a different compilerI already changed the compiler. Now I am developing in assembly with the old good MASM32, and the results are better: no more need to patch structures. But getting x and y resolution always returns a container structure that is different from the one described in twain.inc
>> And on the side, what device are you test with?
Avision AV 820C. But I have ordered a Kodak i1210 and it should be arriving this week.
I am also planning to change the development PC and install another copy of WinXP.
Regards. Alvise.
Try to open a WinXP virtual machine and run the software in that shell.
Alvise.
Yes Jim, the pragma directive is exactly the one that you have typed. Afterall it comes with the original twain.h, and I have no reason to change it. And in fact I haven’t.
I confirm what you say, __BORLANDC__ is the compiler identifier, and for the Borland’s compiler the directive is #pragma -a2 and not #pack (2).
And looking into the data segment, the structures appear to be word aligned (every 2 bytes, even addresses, according to the #pragma -a2 directive). But the fact is that words in the data segment appear to be swapped.
Thanks for your interest. Alvise.
For those who are interested: I further investigated the container that is passed from the Data Source to the application (MSG_GET) and vice-versa (MSG_SET).
When I look into memory at the address allocated for the TWON_ONEVALUE container during the MSG_GET of ICAP_XRESOLUTION I can see:
0x02580000
0xXXXX0007where the first doubleword is Frac+Whole, and the preceeding word (0x0007) is TWTY_FIX32 twain type. Frac, the upper word, is 0x0258 (=600 dpi) and I already said in my previous post that Whole and Frac get exchanged. The word 0xXXXX that preceedes the container is not part of it, but for the sake of completeness its values is 0x0032.
When I allocate the container to perform a MSG_SET of the ICAP_XRESOLUTION, on the contrary, the memory looks like this:
0x000000C8
0xXXXX0007(0x00C8 = 200 dpi) and when I call the DSM entry point I invariably get a TWCC_BADVALUE return code, even if I exchange the words in the Item (0x00C80000) to mimic the MSG_GET arrangement.
By manually changing the contents of the memory, I discovered that the only way to receive the TW_OK status when returning from a call to the DSM entry point, is to set 0xXXXX to the exact same value that it is set when returning from a MSG_GET (0x0032). Any other value makes the MSG_SET fail.
Nonetheless, returning an OK twain status when returning from such a call, the resolution is supposed to be set to the new value… but as I make a successive query (with a further MSG_GET), the resolution is still set to 600 dpi (with Whole and Frac exchanged).
Quote:Is that mean MSG_GET will get two value(the default one and the current one)?The retrieved values depend on the capability that you’re querying and the container that you’re using to retrieve the values.
If you use a container that can contain only one value you’ll retrieve exactly one value.
Hi Gabe, following your suggestion I had a closer look at the free EzTwain package that comes from Dosadi and I discovered how to fit a TW_FIX32 into the Item member of a TW_CONTAINER structure. It’s very simple.
Since the Item is a doubleword (32 bit) and each member of the TW_FIX32 structure is a single word (16 bit), simply memcpy 16+16 into 32 bit when setting the capability, and memcopy 32 bit into 16+16 when getting the capability (in C or C++ it needs appropriate casting, of course).
The EzTwain source code also shows that whatever the capability (TW_UINTxx or TW_FIX32), the function named “TWAIN_SetCapOneValue” gets the capability parameter as a long (=32 bit), then assigns it to Item with the simple assignment operator (=). Very clever.
And also this demostrates that when using a TW_FIX32 type, you can deal with it as if it were a regular long type as long as the Frac member is zero. In fact Frac is set in the upper 16 bit of the long, and Whole in the lower 16 bit.
Well, once I understood how to deal with TW_FIX32 into the Item member of a TW_CONTAINER structure, I have decided to get the current value of the ICAP_XRESOLUTION of my Avision 820C scanner, just to see what it looks like, and subsequently try to set my own value.
The DG_CONTROL, DAT_CAPABILITY, MSG_GET triplet works fine but the TW_FIX32 resolution value that I get looks like this:
resolution.Whole = 0;
resolution.Frac = 600;Since the default resolution of the Avision 820C scanner is 600 dpi, it is evident that the two members of the structure have been exchanged. Ahhh, this is why every time I try to SET the resolution I get a TWCC_BADVALUE condition code in return ! (I thought).
But to make things short, whatever combination of Whole and Frac values I try to set into my scanner, the return status is always the same: bad value.
So I am currently desperate, but will not surrender.
Your code looks pretty good. “Item”, also, is set correctly. Are you setting this capability in TWAIN state == 4 ???
I suppose you get rc > 0 after calling the DSM entry point.
Have you checked the TWAIN status using this triplet: DG_CONTROL, DAT_STATUS, MSG_GET ? Which is the status that you get ?
(Currently I am receiving several TWCC_BADVALUE, but just when I try to set a TW_FIX32 capability.)
- AuthorPosts