Forums › TWAIN Classic › ICAP_BRIGHTNESS › Reply To: ICAP_BRIGHTNESS
@gabe wrote:
if you are using the source code from codeproject as-is (at least as-is from the last time I checked it) there is a problem with NetMaster’s twCapability ctor. He assumes in his sample a static baseAddress size where he should have either calcualted the baseAddress size based on the ItemType or assumed a slightly larger baseAddress size. The result is that FIX32 types don’t work. It’s i nthe forumn comments on tha pag.
Gabe, thank you for your quick reply. I added another contructor like this:
public TwCapability(TwCap cap, TwFix32 val)
{
Cap = (short)cap;
ConType = (short)TwOn.One;
Handle = Twain.GlobalAlloc(0x42, 6);
IntPtr pv = Twain.GlobalLock(Handle);
Marshal.WriteInt16(pv, 0, (short)TwType.Fix32);
Marshal.WriteInt16(pv, 2, val.Whole);
if (val.Frac > Int16.MaxValue)
{
Marshal.WriteInt16(pv, 4, Convert.ToInt16(val.Frac – 32768));
}
else
{
Marshal.WriteInt16(pv, 4, Convert.ToInt16(val.Frac));
}
Twain.GlobalUnlock(Handle);
}
And I believe my Fix32 value is correctly passed into TWAIN Data Source since i get Success status, and also when I after that ask data source for it’s value, it returns me the same value I set. The problem is that GUI doesn’t reflect negotiated capabilities. Any ideas?