Setting the TWAIN Image Acquisition Mode

 

There are functions in the BiTWAIN.DLL and properties in the BiTWAIN.OCX for setting the acquisition mode.

You can scan to memory, to a file on disk or to the clipboard.

 

The difference between Acquire function and BatchScan function is that BatchScan always transfers the images to the BiTwain.dll in memory (TWSX_NATIVE mode) and uses the BiTIFF.dll to save the images to a TIFF file.

 

If a filename is given, Acquire function saves the images to disk directly in a format the scanner driver supports (TWSX_FILE mode), or returns a handle to a DIB if NULL is passed in the filename parameter (TWSX_NATIVE mode). When using Acquire with TWSX_FILE mode, the supported file type also depends on the scanner driver capability. Some scanner supports only bmp (bitmap) and some scanner supports multiple file types.

 

In the Twain C++ Sample, the “Software Batch Scan” option uses the BatchScan function; “Hardware Batch Scan” uses Acquire with TWSX_FILE mode.

 

Scanners are required to support TWSX_NATIVE transfer mode, but not required to support TWSX_FILE transfer mode, so BatchScan should work in all cases.

 

BiTwain.dll:

 

 

BiTwain.ocx:

 

 

[C++]

 

/* Acquire an image to a disk file */

 

#include “BiTwain.h”

 

/* 1. parameter: number of pages to scan It scans only one

page

   2. parameter: the scans single page files or multipage

image */

 

SetAcquirePages(1, FALSE);

 

/* 1. parameter: Path and name of the file to scan */

 

Acquire(_T(“C:\\Images\\Test.tif”));

 

[C#]

 

/* Acquire an image to a disk file */

 

/*Path and name of the file to scan */

 

BiTwain.FileAcquire = “C:\\Images\\Test.tif”;

 

/* 1. parameter: number of pages to scan It scans only one

page

   2. parameter: the scans single page files or multipage

image */

 

BiTwain.SetAcquirePages(1, false);

 

/* Start scanning */

 

BiTwain.Action =

(short)BITWAINLib.enumScanOperations.TWSCAN_ACQUIRE;