←Select platform

FindFastConfiguration Method


(Document/Medical only) Determines the best scanner configuration.



The path to the working folder in which to save the tested images.

Indicates whether to display the manufacturer's user interface. For a list of possible values, refer to the Leadtools.Twain.TwainFastUserInterfaceFlags Flags that control the display of the user interface and the actions of the method.

The resulting file's pixel depth.

Note that not all bits per pixel are available to all file formats. Use 0 for bitsPerPixel to store the file using the closest BitsPerPixel value supported by that format.

The number of memory configurations that will be tested. The maximum value for this parameter is 10.

The configurations to be tested.

Return Value

A TwainFindFastConfigurationResult which represents the best and fastest configuration for the test TWAIN source.


To scan images as quickly as possible, it is necessary to use the fastest scan configuration. Use FindFastConfiguration to test scan configurations for the scanner selected using the SelectSource method.

  • To test user-defined or custom configurations, pass an array of TwainFastConfiguration objects to the userConfigurations parameter of the FindFastConfiguration method.

  • To test the default configurations available for the TWAIN driver, pass null for the userConfigurations parameter.

    • Shorten the list of default scan configurations to test by using the FindConfiguration method to get a list of default scan configurations based on transfer mode, bits per pixel, and the number of buffers. A list of scan configurations will be returned. Next, pass the returned array of TwainFastConfiguration objects as the userConfigurations parameter of the FindFastConfiguration method.
  • To test all supported bits per pixel for the selected scanner, set TwainFastUserInterfaceFlags.CheckDefaultBitsPerPixel in flags. If this flag is not set, the method will test the bits per pixel specified in the bitsPerPixel parameter.

  • If TwainFastUserInterfaceFlags.UseThread is set in flags, the image acquisition process will run in thread mode. In some scanners, acquiring images in thread mode will improve the speed at which the image(s) is(are) acquired. In other scanners (for example, high-speed scanners), acquiring the image(s) in thread mode will provide little to no improvement in the speed at which one or more images are acquired.

  • The bitsPerPixel parameter and the TwainFastUserInterfaceFlags.CheckDefaultBitsPerPixel flag will be used only if the transfer mode for the scan configuration being tested is TwainTransferMechanism.Memory or TwainTransferMechanism.Native.

  • The bufferIteration value determines the buffer sizes to be tested. The purpose for testing the memory transfer mode with different buffer sizes is to determine the buffer size that will provide the fastest scan configuration. The buffer iteration specifies the number of buffer sizes that will be tested. The buffer size is the size of the transferred data from the TWAIN source.

  • To stop the scan configuration testing process, set the Stop property to true within the FastConfiguration event. To continue the scan configuration process, set the Stop property to false.

For more information, refer to Fast TWAIN (Scan Configurations). This function shows some helper message boxes while it is running for guiding the user through the running tests. If you wish to suppress these messages then pass TwainFastUserInterfaceFlags.SuppressMessageBoxes flag and these messages will stop showing up.

using Leadtools; 
using Leadtools.Twain; 
public void twain_FastConfiguration(object sender, TwainFastConfigurationEventArgs e) 
   // ... set your code here 
   e.Stop = false; 
public void FindFastConfigurationExample(IntPtr parent) 
   TwainSession session = new TwainSession(); 
   session.Startup(parent, "manufacturer", "productFamily", "version", "application", TwainStartupFlags.None); 
   session.EnableFastConfigurationEvent = true; 
   session.FastConfiguration += new EventHandler<TwainFastConfigurationEventArgs>(twain_FastConfiguration); 
   List<TwainFastConfiguration> twFastConfig = new List<TwainFastConfiguration>(); 
   TwainFastConfiguration tempFastConfig = new TwainFastConfiguration(); 
   tempFastConfig = TwainFastConfiguration.Default; 
   tempFastConfig.TransferMechanism = TwainTransferMode.File; 
   tempFastConfig.ImageFormat = Leadtools.RasterImageFormat.Bmp; 
   tempFastConfig.BitsPerPixel = 1; 
   tempFastConfig.TransferMechanism = TwainTransferMode.File; 
   tempFastConfig.ImageFormat = Leadtools.RasterImageFormat.Tif; 
   tempFastConfig.BitsPerPixel = 1; 
   TwainFindFastConfigurationResult fastConfigRes; 
      fastConfigRes = session.FindFastConfiguration(Path.Combine(LEAD_VARS.ImagesDir, ""), TwainFastUserInterfaceFlags.Show, 0, 1, twFastConfig); 
      string msg; 
      MessageBox.Show("FindFastConfig method was successful"); 
      msg = String.Format("Result Scan Configs count = {0}", fastConfigRes.Tested.Count); 
      msg = String.Format("Transfer Mode = {0}\nFile Format = {1}\nBuffer Size = {2}\nRequired Time = {3}\n", 
      MessageBox.Show(msg, "Tested Scan Configurations..."); 
      msg = String.Format("Transfer Mode = {0}\nFile Format = {1}\nBuffer Size = {2}\nRequired Time = {3}\n", 
      MessageBox.Show(msg, "Best Scan Configurations..."); 
   catch (Exception ex) 
static class LEAD_VARS 
   public const string ImagesDir = @"C:\LEADTOOLS23\Resources\Images"; 

Target Platforms

Help Version 23.0.2024.2.29
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2024 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.Twain Assembly

Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.