public int BufferSize { get; set; }
The configuration buffer size, in bytes.
Use 0 to use the TWAIN driver preferred buffer size: Otherwise, specify the actual buffer size. This value must be a multiple of 16. For more information, refer to Fast TWAIN (Scan Configurations).
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;
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:\LEADTOOLS23\Resources\Images";
}