Home › Forums › TWAIN Classic › How to fit a TW_FIX32 value into a TW_ONEVALUE › Reply To: How to fit a TW_FIX32 value into a TW_ONEVALUE
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.