May 6, 2008 at 11:38 am #22332
I was disappointed to discover that the SupportedGroups member of the TW_I_DEN_TI_TY(*) structure is NOT a TW_UINT32 type but TW_UINT16 instead (see: http://www.twain.org/devfiles/twain.h and the twain.h that comes with the developer toolkit, both are wrong).
Remember to update your copy of twain.h or you’ll lose time.
(*) sorry I had to add several underscore because the forum editor prevents me to type the exact word, but you understand what I meanMay 6, 2008 at 5:43 pm #24484
I just looked at the TW_IDENT ITY structure of several version of twain.h including the TWAIN Developers Toolkit, and all versions are correct and the same:
Where is the version of twain.h that has SupportedGroups as TW_UINT16?
(*) The form editor does not like the word i d e n t i t
Very strange 🙁 ?May 6, 2008 at 6:21 pm #24485
I can’t answer to your question, I’ve corrected my header myself. The fact is the following: after a few hours of debug I noticed that the following strings:
were shifted 2 bytes left. I.e: KODAK would have read DAK. And the SupportedGroups was an impossible number. As soon as I have modified the type of SupportedGroups from TW_UINT32 from TW_UINT16 all the strings got right (i.e.: KODAK was read KODAK) and the SupportedGroups was the true OR of DG_CONTROL and DG_IMAGE. Incredible, but true.
Now I am spending my time trying to set a TW_FIX32 capability (CAP_XRESOLUTION) using a TWON_ONEVALUE container. It looks like a “mission impossible”.
Any help about this ?
AlviseMay 6, 2008 at 6:30 pm #24486
Sounds like the structure packing is not set to 2
#pragma pack (2)
This is done automatically if you are including twain.h to get the structures. If you are defining your own structures then you will need to do this yourself.
JimMay 6, 2008 at 7:30 pm #24487
Hi Jim, thanks for your interest. I am not defining my own structures, I have naturally included twain.h “as is”. I am using an old -but good- RAD, the Borland C++ Builder Pro release 3 (ehm, it dates back to 1997…) that I have installed in my Windows XP PC.
The pragma directive that you mention is obviously included in the header, but in the “#else” case of an “#ifdef __BORLANDC__” structure.
I am wondering whether I should reverse the cases in the ifdef structure, but I am not that expert to take such an initiative. At the same time I am wondering whether the absence of the #pragma pack (2) directive could be the cause of all the troubles that I am stumbling into (lots of TWCC_BADVALUE” when setting capabilities).
I need to get uncompressed B&W letter size images at 200 dpi from any TWAIN scanner, and I also am in a hurry. I am also considering to switch using the ISIS device driver, although this would mean restart programming from scratch.
Regards from Alvise.May 7, 2008 at 3:29 pm #24488
Hi Jim, I’ve added the directive that you have suggested (#pragma pack (2)), but this did not solve the problems.
Regards. Alvise.May 7, 2008 at 4:06 pm #24489
For those who are interested: into the TW_ID_ENT_ITY structure I’ve changed:
and now everything works fine. The dummy word is set to zero.
Without the dummy word the following TW_STR32 strings would get shifted a couple of bytes right.
Alvise.May 9, 2008 at 7:56 pm #24490
I still believe that the structure packing is not correct.
twain.h uses __BORLANDC__ to determine if you are using a Borland compiler. Make sure this is set in your environment. The switch for Borland is different than the one I gave earlier.
#pragma option -a2
Jim WattersMay 9, 2008 at 8:24 pm #24491
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.May 19, 2008 at 5:51 am #24492
I agree with Jim. I’ve used SupportedGroups successfully with nothing more than an #import twain.h. The structure works… or more precisely – the structure works from vs6 and vs2005.
Again, not saying there is anything wrong with borland – just that you aren’t getting the same results I am from what sounds like the same code.
.May 19, 2008 at 7:41 am #24493
or to answer this in another way – when you run the toolkit sample – do you see the same problem with the structure?
.May 19, 2008 at 7:48 am #24494
Toolkit sample ? I didn’t notice it. Today I’ll re-inspect the package.
Thanks for the hint. Alvise.May 19, 2008 at 8:18 am #24495
- This topic has 12 replies, 3 voices, and was last updated 12 years, 4 months ago by .
Viewing 13 posts - 1 through 13 (of 13 total)
Viewing 13 posts - 1 through 13 (of 13 total)