How to Acquire from the TWAIN Source
After the user has established a TWAIN session, selected a TWAIN source, and set the desired capabilities of the TWAIN source, he or she is ready to acquire images or image data from that source. LEADTOOLS provides the following functions for acquiring images and image data from a TWAIN source:
The L_TwainAcquire
function acquires one or more images from a TWAIN source. If the user
has defined an LTWAINBITMAPCALLBACK function and passed a pointer to this
function to L_TwainAcquire, the callback function will receive each image
acquired from the source. This allows the user to process each image as
desired. If only one image is acquired, and the user does not supply a
callback function, the pBitmap parameter of L_TwainAcquire is updated
with the acquired image. Within the LTWAINBITMAPCALLBACK function the
user can call the L_TwainGetExtendedImageInfo
to get extended image information that is included if the TWAIN source
is a barcode reader or a digital camera. L_TwainFreeExtendedImageInfoStructure
will free the TW_EXTIMAGEINFO structure that the L_TwainGetExtendedImageInfo
function retrieves. For more information about TW_EXTIMAGEINFO, refer
to the TWAIN 1.9 specification from the site "http://www.twain.org/".
The L_TwainAcquireList
function acquires one or more images from the TWAIN source and stores
them in the specified LEAD bitmap list.
The L_TwainAcquireMulti
or L_TwainFastAcquire function
acquires one or more images from a TWAIN source and saves the image(s)
to one or more files. If the file format used does not support multi-page
files, then the images will be saved to a series of files named by appending
the image number to a base file name. If the file format used does support
multi-page files, then the image(s) will be saved to one or more files
based on the bMultiPageFile parameter.
If this parameter is FALSE, then images will be saved to a series of files
named by appending the image number to a base file name. If this parameter
is TRUE, the image(s) will be saved to one multi-page file named using
only the base file name.
The L_TwainAcquireMulti function takes an optional parameter a pointer to an LTWAINACQUIRECALLBACK callback function. This callback function is called twice for each page scanned using the L_TwainAcquireMulti function. It is called the first time when the Twain source begins scanning the page. It is called the second time when the Twain source has finished scanning the page.
To cancel a TWAIN acquisition operation, started by calling the L_TwainAcquireMulti function, call L_TwainCancelAcquire inside the LTWAINACQUIRECALLBACK callback function. To cancel a TWAIN acquisition operation, started by calling the L_TwainAcquire function, call L_TwainCancelAcquire inside the LTWAINBITMAPCALLBACK callback function.
The functions listed above can acquire images in the following transfer modes:
Native |
gets the bitmaps being scanned into the memory as a whole. |
Memory Buffered |
gets images from the source as strips of data. These strips can be merged to get the whole image. |
File |
gets the images from the source to a disk file. |
To stop acquire process, you can call L_TwainCancelAcquire inside LTWAINBITMAPCALLBACK for acquire process started by L_TwainAcquire function.
Also, to stop acquire process, you can call L_TwainCancelAcquire inside LTWAINACQUIRECALLBACK for acquire process started by L_TwainAcquireMulti function.
To stop acquiring images only from the feeder of the TWAIN source using the L_TwainAcquire function, call the L_TwainStopFeeder function in the LTWAINBITMAPCALLBACK callback function when it is fired.
To stop acquire images only from the feeder of the TWAIN source using the L_TwainAcquireMulti function, call the L_TwainStopFeeder function in the LTWAINACQUIRECALLBACK callback function when it is fired.