- workingFolder
- The path to the working folder in which to save the tested images.
- flags
- Indicates whether to display the manufacturer's user interface. For a list of possible values, refer to the UserInterfaceConstants enumeration Flags that control the display of the user interface and the actions of the method.
- bitsPerPixel
- 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.
- bufferIteration
- The number of memory configurations that will be tested. The maximum value for this parameter is 10.
- userConfigurations
- The configurations to be tested.
Visual Basic (Declaration) | |
---|---|
Public Function FindFastConfiguration( _ ByVal workingFolder As String, _ ByVal flags As TwainFastUserInterfaceFlags, _ ByVal bitsPerPixel As Integer, _ ByVal bufferIteration As Integer, _ ByVal userConfigurations As RasterCollection(Of TwainFastConfiguration) _ ) As TwainFindFastConfigurationResult |
Visual Basic (Usage) | Copy Code |
---|---|
Dim instance As TwainSession Dim workingFolder As String Dim flags As TwainFastUserInterfaceFlags Dim bitsPerPixel As Integer Dim bufferIteration As Integer Dim userConfigurations As RasterCollection(Of TwainFastConfiguration) Dim value As TwainFindFastConfigurationResult value = instance.FindFastConfiguration(workingFolder, flags, bitsPerPixel, bufferIteration, userConfigurations) |
C# | |
---|---|
public TwainFindFastConfigurationResult FindFastConfiguration( string workingFolder, TwainFastUserInterfaceFlags flags, int bitsPerPixel, int bufferIteration, RasterCollection<TwainFastConfiguration> userConfigurations ) |
C++/CLI | |
---|---|
public: TwainFindFastConfigurationResult FindFastConfiguration( String^ workingFolder, TwainFastUserInterfaceFlags flags, int bitsPerPixel, int bufferIteration, RasterCollection<TwainFastConfiguration>^ userConfigurations ) |
Parameters
- workingFolder
- The path to the working folder in which to save the tested images.
- flags
- Indicates whether to display the manufacturer's user interface. For a list of possible values, refer to the UserInterfaceConstants enumeration Flags that control the display of the user interface and the actions of the method.
- bitsPerPixel
- 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. - bufferIteration
- The number of memory configurations that will be tested. The maximum value for this parameter is 10.
- userConfigurations
- The configurations to be tested.
Return Value
A TwainFindFastConfigurationResult which represents the best and fastes configuration for the test TWAIN source.Visual Basic | Copy Code |
---|---|
Public Sub twain_FastConfiguration(ByVal sender As Object, ByVal e As TwainFastConfigurationEventArgs) ' ... set your code here e.Stop = False End Sub Public Sub FindFastConfigurationExample(ByVal parent As IWin32Window) Dim session As TwainSession = New TwainSession() session.Startup(parent, "manufacturer", "productFamily", "version", "application", TwainStartupFlags.None) session.EnableFastConfigurationEvent = True AddHandler session.FastConfiguration, AddressOf twain_FastConfiguration Dim twFastConfig As RasterCollection(Of TwainFastConfiguration) = Nothing Dim tempFastConfig As TwainFastConfiguration = New TwainFastConfiguration() tempFastConfig = TwainFastConfiguration.Default tempFastConfig.TransferMechanism = TwainTransferMode.File tempFastConfig.ImageFormat = Leadtools.RasterImageFormat.Bmp tempFastConfig.BitsPerPixel = 1 twFastConfig.Add(tempFastConfig) tempFastConfig.TransferMechanism = TwainTransferMode.File tempFastConfig.ImageFormat = Leadtools.RasterImageFormat.Tif tempFastConfig.BitsPerPixel = 1 twFastConfig.Add(tempFastConfig) Dim fastConfigRes As TwainFindFastConfigurationResult Try fastConfigRes = session.FindFastConfiguration(Path.Combine(LEAD_VARS.ImagesDir, ""), TwainFastUserInterfaceFlags.Show, 0, 1, twFastConfig) Dim msg As String MessageBox.Show("FindFastConfig method was successful") msg = String.Format("Result Scan Configs count = {0}", fastConfigRes.Tested.Count) MessageBox.Show(msg) msg = String.Format("Transfer Mode = {0}" & Constants.vbLf & "File Format = {1}" & Constants.vbLf & "Buffer Size = {2}" & Constants.vbLf & "Required Time = {3}" & Constants.vbLf, fastConfigRes.Tested(0).TransferMechanism, fastConfigRes.Tested(0).ImageFormat, fastConfigRes.Tested(0).BufferSize, fastConfigRes.Tested(0).RequiredTime) MessageBox.Show(msg, "Tested Scan Configurations...") msg = String.Format("Transfer Mode = {0}" & Constants.vbLf & "File Format = {1}" & Constants.vbLf & "Buffer Size = {2}" & Constants.vbLf & "Required Time = {3}" & Constants.vbLf, fastConfigRes.Best.TransferMechanism, fastConfigRes.Best.ImageFormat, fastConfigRes.Best.BufferSize, fastConfigRes.Best.RequiredTime) MessageBox.Show(msg, "Best Scan Configurations...") Catch ex As Exception MessageBox.Show(ex.Message) End Try session.Shutdown() End Sub Public NotInheritable Class LEAD_VARS Public Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images" End Class |
C# | Copy Code |
---|---|
public void twain_FastConfiguration(object sender, TwainFastConfigurationEventArgs e) { // ... set your code here e.Stop = false; } public void FindFastConfigurationExample(IWin32Window parent) { TwainSession session = new TwainSession(); session.Startup(parent, "manufacturer", "productFamily", "version", "application", TwainStartupFlags.None); session.EnableFastConfigurationEvent = true; session.FastConfiguration += new EventHandler<TwainFastConfigurationEventArgs>(twain_FastConfiguration); RasterCollection<TwainFastConfiguration> twFastConfig = null; TwainFastConfiguration tempFastConfig = new TwainFastConfiguration(); tempFastConfig = TwainFastConfiguration.Default; tempFastConfig.TransferMechanism = TwainTransferMode.File; tempFastConfig.ImageFormat = Leadtools.RasterImageFormat.Bmp; tempFastConfig.BitsPerPixel = 1; twFastConfig.Add(tempFastConfig); tempFastConfig.TransferMechanism = TwainTransferMode.File; tempFastConfig.ImageFormat = Leadtools.RasterImageFormat.Tif; tempFastConfig.BitsPerPixel = 1; twFastConfig.Add(tempFastConfig); TwainFindFastConfigurationResult fastConfigRes; try { 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); MessageBox.Show(msg); msg = String.Format("Transfer Mode = {0}\nFile Format = {1}\nBuffer Size = {2}\nRequired Time = {3}\n", fastConfigRes.Tested[0].TransferMechanism, fastConfigRes.Tested[0].ImageFormat, fastConfigRes.Tested[0].BufferSize, fastConfigRes.Tested[0].RequiredTime); MessageBox.Show(msg, "Tested Scan Configurations..."); msg = String.Format("Transfer Mode = {0}\nFile Format = {1}\nBuffer Size = {2}\nRequired Time = {3}\n", fastConfigRes.Best.TransferMechanism, fastConfigRes.Best.ImageFormat, fastConfigRes.Best.BufferSize, fastConfigRes.Best.RequiredTime); MessageBox.Show(msg, "Best Scan Configurations..."); } catch (Exception ex) { MessageBox.Show(ex.Message); } session.Shutdown(); } static class LEAD_VARS { public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images"; } |
This method will test scan configurations for the scanner selected using the Leadtools.Twain.TwainSession.SelectSource method. Using the fastest scan configuration lets you scan images as quickly as possible. To test user-defined or custom configurations, pass an arry of TwainFastConfiguration objects to the userConfigurations parameter of the TwainSession.FindFastConfiguration method.
To test the default configurations available for the TWAIN driver, pass null for the userConfigurations parameter. The list of default scan configurations to test can be shortened by using the FindConfiguration method to get a list of default scan configurations based on transfer mode, bits per pixel and 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 TwainSession.FindFastConfiguration method. Call the FindFastConfiguration method to determine the best and fastest scan configuration.
If TwainFastUserInterfaceFlags.CheckDefaultBitsPerPixel is set in flags then the method will test all supported bits per pixel for the selected scanner. If this flag is not set, then the method will test the bits per pixel specified in the bitsPerPixel parameter.
If TwainFastUserInterfaceFlags.UseThread is set in flags, then the image acquisition process will run in thread mode. In some scanners, acquiring images in thread will improve the speed at which the image(s) is(are) acquired. In other scanners, high-speed scanners, for example, acquiring the image(s) in thread mode will provide little to no improvement in the speed at which the image(s) is(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 buffer iteration 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 TwainFastConfigurationEventArgs.Stop property to true within the TwainSession.FastConfiguration event. The TwainFastConfigurationEventArgs.Stop property must be set to false to continue the scan configuration process.
For more information, refer to Fast TWAIN (Scan Configurations).
To test the default configurations available for the TWAIN driver, pass null for the userConfigurations parameter. The list of default scan configurations to test can be shortened by using the FindConfiguration method to get a list of default scan configurations based on transfer mode, bits per pixel and 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 TwainSession.FindFastConfiguration method. Call the FindFastConfiguration method to determine the best and fastest scan configuration.
If TwainFastUserInterfaceFlags.CheckDefaultBitsPerPixel is set in flags then the method will test all supported bits per pixel for the selected scanner. If this flag is not set, then the method will test the bits per pixel specified in the bitsPerPixel parameter.
If TwainFastUserInterfaceFlags.UseThread is set in flags, then the image acquisition process will run in thread mode. In some scanners, acquiring images in thread will improve the speed at which the image(s) is(are) acquired. In other scanners, high-speed scanners, for example, acquiring the image(s) in thread mode will provide little to no improvement in the speed at which the image(s) is(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 buffer iteration 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 TwainFastConfigurationEventArgs.Stop property to true within the TwainSession.FastConfiguration event. The TwainFastConfigurationEventArgs.Stop property must be set to false to continue the scan configuration process.
For more information, refer to Fast TWAIN (Scan Configurations).
Target Platforms: Microsoft .NET Framework 2.0, Windows 2000, Windows XP, Windows Server 2003 family, Windows Server 2008 family, Windows Vista, Windows 7