Buffered Transfer

Top  Previous  Next

The Buffered Transfer Mode (also called Memory transfers) transfers the image from the Source to the application in individual strips or tiles.  The Buffered Mode is supported by all Sources, with some of these Sources capable of doing compressed transfers (see below).

 

Transferring images using the Buffered Transfer mode is less memory intensive than the Native Mode, since the data is not transferred as a single block, but as many individual blocks (or buffers), one at a time until the whole page is acquired.  This mode should be used if the image to transfer uses a large amount of memory, or if the buffered image data is being transferred as tiles instead of strips.  

 

The function that acquires images using the buffered transfer mode is DTWAIN_AcquireBuffered.

 

DTWAIN's implementation of the buffered transfer mode currently supports the DIB format for uncompressed data and also non-DIB, compressed formats.  The function that sets the type of compression (or no compression) is DTWAIN_SetCompressionType.  If no compression is desired, DTWAIN generates DIBs (just like the native transfer mode).  If compression is on, DTWAIN returns a memory block that represents the image data.  This data can be saved to the actual image file if necessary.

 

DTWAIN supports buffered transfers using strips and tiles.  Transferring the data as tiles is only supported if the device sending the tiled data has support for the ICAP_TILES capability.



Acquiring images as strips 


Note that by default, DTWAIN will create the entire image in memory, thus all the memory related handling is done internally by DTWAIN, and no user-defined buffer needs to be created by the application.  In this scenario, it is as simple as calling DTWAIN_AcquireBuffered or DTWAIN_AcquireBufferedEx without any further setup by the application.  


However, tf there are constraints on the memory usage, a user-defined buffer can be established.  With a user-defined buffer, DTWAIN allocates no memory, and the application is responsible for any memory allocation / deallocation issues.  If your application requires a user-defined memory buffer to acquire the buffered image, see Acquire using strips for step-by-step instuctions on how to set the memory buffer in your application.  



Acquiring images as tiles


Sending tiled data is implemented by very few TWAIN Sources, however there is support for this transfer type in DTWAIN.  If the device is sending tiled data, your application will be sent a DTWAIN_TN_TRANSFERTILEDONE notification, indicating that a tile has been transferred, and your application has to process the new tile by getting the information on the tile by calling DTWAIN_GetBufferedTransferInfo().  Note that DTWAIN will handle the deallocation of the tile data once the application has finished processing the individual tile.  See Acquire using tiles for more information.