LEADTOOLS TWAIN Send comments on this topic. | Back to Introduction - All Topics | Help Version 17.0.3.22
Fast TWAIN (Scan Configurations)

The performance of a TWAIN scanner can vary based on its scan configuration. The TWAIN driver of your TWAIN scanner comes with one or more "default" scan configurations. In addition, the user may create one or more user-defined scan configurations. LEAD provides several functions to determine the best and fastest scan configuration available, thereby letting you use the best and fastest scan configuration for scanning images.

To determine the best and fastest scan configuration for your TWAIN scanner, call the TwainSession.FindFastConfiguration method. This method will test either an array of user-defined scan configurations, or all the default scan configurations present for the TWAIN driver of the current TWAIN scanner, based on the values of the userConfiguration parameter that is passed to this method. For each scan configuration that is tested, the TwainSession.FastConfiguration event is fired, if the TwainSession.EnableFastConfigurationEvent property has been set to TRUE. This event receives the information for the scan configuration being tested. This lets you interact with the scan configuration information as needed. When the TwainSession.EnableFastConfigurationEvent event is fired, you can check the success status of the scan configuration being tested by getting the TwainFastConfiguration.Success property.

The scan configuration testing process, started by the TwainSession.FindFastConfiguration method, can be stopped by setting the TwainFastConfigurationEventArgs.Stop property to TRUE inside the TwainSession.FastConfiguration event. To continue the scan configuration process, set the TwainFastConfigurationEventArgs.Stop property to FALSE.

Since the list of default scan configurations present for a specific TWAIN driver can be rather numerous, you can narrow the list you wish to test using the TwainSession.FindConfiguration method. This method gets default scan configurations based on the transfer mode, bits per pixel and number of buffers. Therefore, the return value of this method is an array contains a list of scan configurations for a specific transfer mode, pass this array to the userConfiguration parameter of the TwainSession.FindFastConfiguration method. This will decrease the number of default scan configurations that must be tested. The return value of the TwainSession.FindFastConfiguration method is a TwainFindFastConfigurationResult structure, which contains the following two properties:

Once the best scan configuration has been determined, the scan configuration information in the TwainFindFastConfigurationResult.Best property can be used to set the values for the TwainFastConfiguration.TransferMechanism property, the TwainFastConfiguration.ImageFormat property, the TwainFastConfiguration.BitsPerPixel property, TwainFastConfiguration.BufferSize property, then the TwainSession.AcquireFast method can be called so the images will be acquired as fast as possible.

Scan configurations are accessed through a TwainFastConfiguration class, which contains the following properties: