Leadtools.Twain Namespace > TwainSession Class : FindFastConfiguration Method |
public TwainFindFastConfigurationResult FindFastConfiguration( string workingFolder, TwainFastUserInterfaceFlags flags, int bitsPerPixel, int bufferIteration, RasterCollection<TwainFastConfiguration> userConfigurations )
'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
'Usage 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)
public TwainFindFastConfigurationResult FindFastConfiguration( string workingFolder, TwainFastUserInterfaceFlags flags, int bitsPerPixel, int bufferIteration, RasterCollection<TwainFastConfiguration> userConfigurations )
function Leadtools.Twain.TwainSession.FindFastConfiguration( workingFolder , flags , bitsPerPixel , bufferIteration , userConfigurations )
public: TwainFindFastConfigurationResult FindFastConfiguration( String^ workingFolder, TwainFastUserInterfaceFlags flags, int bitsPerPixel, int bufferIteration, RasterCollection<TwainFastConfiguration>^ userConfigurations )
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
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"; }
Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2