Hi,
While debugging twain, I came across the nativexfer method, used by 60-70% of all twain using programs.
It has some very unfortunate programming logic.
Here is a sample snippet from: http://hp.vector.co.jp/authors/VA011973/prg_twain.htm
TW_UINT16 rc; TW_UINT32 hBitmap; TW_BOOL PendingXfers = TRUE; LPBITMAPINFOHEADER lpDib;
hBitmap = NULL; rc = lpfnDSM_Entry(pAppId,pSourceId,DG_IMAGE,DAT_IMAGENATIVEXFER,MSG_GET,(TW_MEMREF)&hBitmap); lpDib = (LPBITMAPINFOHEADER)GlobalLock((void*)hBitmap); /* ... */ if(lpdib!=NULL){ GlobalUnlock((void*)hBitmap); GlobalFree((void*)hBitmap); }
(hBitmap is the return value of CreateDIBSection()).
This sample code apparently assumes that GlobalLock(HBITMAP) gives it a pointer to a BITMAPINFOHEADER.
We do not do this, for us HBITMAP is a regular 16bit GDI handle. GlobalLock will not work on it :/
Any ideas?
Ciao, Marcus