Available in the LEADTOOLS Imaging toolkit. |
How to Acquire from the TWAIN Source
After the user has initialized 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 for acquiring images and image data from a TWAIN source:
The Acquire method acquires one or more images from a TWAIN source. There are two ways to obtain the acquired images(s):
1. The user sets the SaveAcquiredBitmap property to TRUE before calling the Acquire method. In this case, when calling the Acquire method, the AcquiredBitmapList and AcquiredBitmap properties will be updated with the acquired images(s), but will not trigger the AcquirePageEvent event.
2. The user sets the SaveAcquiredBitmap property to FALSE before calling the Acquire method. In this case, for each image acquired by the Acquire method, an AcquirePageEvent event occurs and the image is passed to the event. The AcquiredBitmapList and AcquiredBitmap properties will not be valid and will not be updated with the acquired images(s). Within the AcquirePageEvent event, the user can call the GetExtImageInfo method to get extended image information that is included if the TWAIN source is a barcode reader or a digital camera.
If you are using the ADF, you can stop feeding pages during the acquisition process by setting the StopFeedPages property value to TRUE in the AcquirePageEvent event. To continue feeding pages during image acquisition, set this property value to FALSE.
The GetExtImageInfo method will store the acquired image information in a pointer to an ItwExtImageInfo interface. This interface has the following properties:
The NumOfInfos property contains the number of entries in the PtwInfo property.
The PtwInfo property is an array of ItwInfo interfaces describing the extended image information retrieved.
The ItwInfo is an interface used in getting information data from an ItwExtImageInfo interface. It has the following properties:
The InfoID property contains the extended image information ID.
The ItemType property contains the data type of the extended information.
The NumOfItems property contains the number of items retrieved for the extended image information.
The CondCode property contains the condition code obtained when getting the extended image information value.
The Item property contains a VARIANT array that contains the extended image information.
The AcquireMulti method acquires one or more images from a TWAIN source and saves the image(s) to one or more files. Several properties are associated with this method and help control the performance of this method, and the TWAIN driver. These properties are: FastTransferMode property, the FastFormat property, the FastBitsPerPixel property, the FastBufferSize property and the FastUsePreferredBufferSize property.
In addition, the parameters passed to the AcquireMulti method dictate the actions of the method. 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 bMulti 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.
For each page scanned using the AcquireMulti method, the AcquireMultiEvent event is fired twice, if the EnableAcquireMultiEvent property is set to TRUE before calling the AcquireMulti method. The AcquireMultiEvent event is fired first when the Twain source begins scanning the page. The event is fired the second time when the Twain source finishes scanning the page.
The Acquire method 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. |
The following properties are used depending on the transfer mode set.:
The FileTransferName property contains the file name that will be used when the transfer mode is set to File.
The MemBufSize property contains the memory buffer size to use when the transfer mode is set to Memory Buffered.
To stop acquire process, you can call CancelAcquire method inside AcquirePageEvent event for acquire process started by Acquire method.
Also, to stop acquire process, you can call CancelAcquire method inside AcquireMultiEvent event for acquire process started by AcquireMulti method.