Set the TWAIN Image Acquisition Mode
There are three acquisition modes in TWAIN:
- Native: ImageGear will load the entire image into memory as one continuous data stream.
- Disk File Transfer: The Data Source will save the acquired image directly to a file. ImageGear gives you control over setting the filename and file format to be used in Setting the Filename and Format Type for Disk File Transfer.
- Buffered Memory Transfer: The data will be loaded into memory (as for Native Transfer) except that it will be buffered and optionally compressed. This allows you to minimize memory requirements which is especially useful when scanning high-resolution images.
Remember that not all of the TWAIN-supported transfer syntax modes are supported by all Data Sources. If you try to use an acquisition mode that your device does not support, you will receive an error message.
Tell ImageGear the transfer mode to use with the function IG_TWAIN_cap_set().
- To set the transfer mode to Disk File Transfer (IG_TW_SX_FILE), Buffered Memory(IG_TW_SX_MEMORY), or Native(IG_TW_SX_NATIVE):
|
Copy Code
|
AT_ERRCOUNT SetTransferMode(DWORD dwXferMode)
{
AT_ERRCOUNT errorCount = 0;
HTWAINCAP hTWAINCap = (HTWAINCAP)NULL;
errorCount = IG_TWAIN_cap_create(IG_TW_ICAP_XFERMECH, IG_TW_ON_ONEVALUE, AM_TID_META_UINT16,
&hTWAINCap);
errorCount += IG_TWAIN_cap_value_set(hTWAINCap, (LPCVOID)dwXferMode, sizeof(dwXferMode));
errorCount += IG_TWAIN_cap_set(hTWAINCap, IG_TW_MSG_SET);
errorCount += IG_TWAIN_cap_delete(hTWAINCap);
return errorCount;
}
|
- To set the transfer syntax call the above function with either IG_TW_SX_FILE, IG_TW_SX_MEMORY, or IG_TW_SX_NATIVE, like so:
|
Copy Code
|
AT_ERRCOUNT errorCount = 0;
// Set to Disk File Transfer mode
errorCount = SetTransferMode(IG_TW_SX_FILE);
// Set to Buffered Memory Transfer mode
errorCount = SetTransferMode(IG_TW_SX_MEMORY);
// Set to Native Transfer mode
errorCount = SetTransferMode(IG_TW_SX_NATIVE);
|
By default, if no call is made to set transfer mode, ImageGear will use the mode set in Data Source.