Acquire using tiles
To acquire using tiles, the application is solely responsible for understanding the information returned to it by DTWAIN when a tile is transferred. Except for the memory management, DTWAIN does no handling of the tiled data to create the image. Most of the work done by the application will be done during notification processing, as detailed in Step 1 and Step 4 below. Step 1: Make sure that DTWAIN Notification processing is enabled, as the tiled data will be presented to your application by notifying the application that a tile has been transferred. Step 2: The first function that your application should call is DTWAIN_IsBufferedTileModeSupported() to ensure that the device supports buffered tiles,
Step 3: Call DTWAIN_SetBufferedTileMode() to set the tile mode to "on" by passing TRUE as the second parameter. Note that DTWAIN_SetBufferedTileMode() will only be successful for devices that support tiled mode processing. Step 3: Call DTWAIN_AcquireBuffered to start the acquisition.
Step 4: In your notification handler (step 1), you should process the DTWAIN_TN_TRANSFERTILEDONE message. Your handler should the call DTWAIN_GetBufferedTransferInfo() to retrieve all the information concerning the tile that was sent. DTWAIN_SOURCE Source; /* ... */ /* Assume Source has been selected and opened */ if ( DTWAIN_SetBufferedTileMode(Source, TRUE) ) { /* Tiling is supported, and has been set to "on" */ } /* ... */ LRESULT MyCallback(WPARAM wParam, LPARAM lPara, LONG UserData) { if ( wParam == DTWAIN_TN_TRANSFERTILEDONE ) { /* Get the buffered tile information */ LONG Compression, BytesPerRow, Columns, Rows, XOffset, YOffset, Flags, BytesWritten, MemoryLength; HANDLE memoryHandle = DTWAIN_GetBufferedTransferInfo(Source, &Compression, &BytesPerRow, &Columns, &Rows, &XOffset, &YOffset, &Flags, &BytesWritten, &MemoryLength); /* The returned memoryHandle is a pointer to the handle returned by the device. Use GlobalLock() on this handle to get the data */ BYTE *data = (BYTE *)GlobalLock(memoryHandle); /* Process the data. This is up to the application and depends on what was filled in by DTWAIN_GetBufferedTransferInfo in the parameter list. */ /* The MemoryLength value that is filled in by DTWAIN_GetBufferedTransferInfo() is the actual length of the memory that memoryHandle is pointing to. */ /* Do not attempt to free the HANDLE memory, as DTWAIN will free the memory once you are done with processing the data. */ return TRUE; } else if ( wParam == DTWAIN_TN_TRANSFERDONE) { /* All tiles have been transferred. Your application can do any final cleanup here.*/ return TRUE; } /*...*/ } //...
Note that you must be familiar with the handling of tiled data, most particulary the XOffset value being returned by DTWAIN_GetBufferedTransferInfo(), as that is an indication of where the tile is placed in the image. |