Getting and Setting Capabilities
Each TWAIN source can support a number of capabilities. These capabilities dictate the behavior of the TWAIN source. Before acquiring images from the selected TWAIN source, the user may wish to examine and change the capability settings for that source.
It is possible to check whether the scanner installed on the system supports certain capabilities. For more information, refer to "How to Find Out Whether Your Scanner Supports Certain Capabilities Using Twacker", which can be found on https://www.leadtools.com/support/forum/. Search for "How to Find Out Whether Your Scanner Supports Certain Capabilities Using Twacker".
LEADTOOLS provides both low-level and high-level functions for getting and setting capabilities. The low-level functions get and set capabilities individually. The high-level functions let the user get and set specific capabilities, either singly or in groups.
Low-Level
- To get information about the capabilities supported by the selected TWAIN source, call the LTwain::EnumCapabilities function. For each capability enumerated by LTwain::EnumCapabilities, this function will call the LTwain::CapabilityCallBack function. Within this callback function the user can process the capability information.
- To get information about a specific capability (current, default, or all possible values), call LTwain::GetCapability. This function gets information about the capability specified in a TW_CAPABILITY structure. For more information about TW_CAPABILITY, refer to the TWAIN specification.
- To set a specific capability to a new value or to reset the value of a capability to the default value, call LTwain::SetCapability.
High-Level
- LTwain::GetProperties and LTwain::SetProperties allow the user to get and set a number of capabilities through the LTWAINPROPERTIES structure. If this structure does not have the capability needed to negotiate, the user may use the low-level functions to do so.
- The LTwain::QueryProperty function lets the user get the available values for a specific capability from the selected source.
- There are several transfer option capabilities that control the file name, compression, transfer mode, and file format. These can be obtained or set collectively using the LTwain::GetTransferOptions and the LTwain::SetTransferOptions functions.
- In addition to the transfer options mentioned above, the transfer modes supported by the TWAIN source can be obtained by calling the LTwain::GetSupportedTransferMode function.
- When transferring files from the TWAIN source there is a maximum number of files that can be transferred. To get the current value, call the LTwain::GetMaxXferCount function. To change that value, call the LTwain::SetMaxXferCount function.
-
There are many capabilities associated with various image characteristics, such as image resolution, image frame, image unit, bits per pixel, etc. The current values for these can be obtained using the following functions:
-
To change the values of these capabilities, use the following functions:
-
Image contrast, highlight and brightness capabilities can be set simultaneously by calling LTwain::SetImageEffects. To find out the current settings for contrast, highlight and brightness, call LTwain::GetImageEffects.
- The RGB elements used by the TWAIN source can be set by calling the LTwain::SetRGBResponse function.
- If the TWAIN source supports duplex scanning, a specific duplex mode can be enabled or disabled by calling LTwain::EnableDuplex. To get the current duplex mode and the enabled status of that mode, call LTwain::GetDuplexOptions.
- The page size and orientation used during image acquisition can be set by calling LTwain::SetAcquirePageOptions. To get the current settings for these page options, call LTwain::GetAcquirePageOptions.
- During the actual acquisition process, you can elect to have a progress indicator displayed. The LTwain::ShowProgress function lets you hide or display the progress indicator.
- The device event capability (CAP_DEVICEEVENT) values for the current TWAIN driver can be set by calling LTwain::SetDeviceEventCapability. To get the device event capability values, call LTwain::GetDeviceEventCapability. To reset the device event capability values, call LTwain::ResetDeviceEventCapability. To get detailed information for a device event, call LTwain::GetDeviceEventData to get the detailed information.
- After setting the desired capabilities call LTwain::Acquire to scan the pages.
To get the custom data of the TWAIN data source, call the LTwain::GetCustomDSData function, which is also saves the custom data to a file.
To set the custom data of the TWAIN data source, call the LTwain::SetCustomDSData function, which is also loads the data from a file.
When working with TW_CAPABILITY structures it may be necessary to create a container associated with that structure. For more information on containers, refer to How to Work with the Containers.