public void AcquireFast(
string baseFileName,
TwainFastUserInterfaceFlags flags,
TwainTransferMode transferMode,
RasterImageFormat format,
int bitsPerPixel,
bool multiPage,
int bufferSize,
bool usePreferredBufferSize
)
baseFileName
The base name of the image file to which to save the acquired data.
flags
Flag that indicates whether to display the manufacturer's user interface.
transferMode
The transfer mode used to acquire the images.
format
The image format used to save the images.
bitsPerPixel
Represents the BitsPerPixel to be used.
multiPage
true for multipage acquire; false for single page.
bufferSize
Specifies the buffer size (in bytes) used to acquire images.
usePreferredBufferSize
Specifies whether to use the preferred buffer size specified by the TWAIN driver.
true to use the preferred buffer size specified by the TWAIN driver; false to use the user-defined buffer size (bufferSize parameter).
AcquireFast and AcquireFast2 are similar to the Acquire method. All are used to acquire one or more images. However, both AcquireFast and AcquireFast2 acquire one or more images and save them to one or more files. In addition, AcquireFast2 allows the starting page number to be specified, to prevent overwriting pages that have already been scanned.
There are two ways to set the scanning configuration. The first way is to determine the configuration before calling AcquireFast, by calling the FindFastConfiguration method to determine the best scan configuration. The second way is to let AcquireFast determine the best method for you.
Note: In fact, if you do not call the FindFastConfiguration method before calling the AcquireFast method, then the AcquireFast method will determine the best/fastest scanning method to use, based on the type of scanner being used.
The format, baseFileName, and multiPage parameters determine how the images are saved, as follows:
If the file format set in the format parameter does not support multipage files, AcquireFast will ignore the multiPage parameter and automatically save the scanned images to separate files. The files are named by appending numbers to the string used for the baseFileName. For example, if the string in baseFileName is "Temp.jpg", the method will append the number of the image (0001, 0002, etc.), to the name of the file. Therefore, the output file names will be "Temp0001.jpg", "Temp0002.jpg", etc.
If the file format specified in the format parameter supports multipage files, AcquireFast will use the multiPage parameter to determine how to save multiple images.
To use the AcquireMultiPage event, set the EnableAcquireMultiPageEvent property value to true before calling the AcquireFast method. The AcquireMultiPage event will be fired twice for each scanned page: the first time when the TWAIN source begins scanning the page, and again when the TWAIN source has finished scanning the page. For more information, refer to How to Acquire from the Twain Source.
For more information, refer to Fast TWAIN (Scan Configurations).
using Leadtools;
using Leadtools.Twain;
public void twain_AcquireMulti(object sender, TwainAcquireMultiPageEventArgs e)
{
string msg;
if (e.FinishScan)
{
msg = String.Format("The page # {0} is scanned and saved to file name {1}", e.PageNumber, e.FileName);
MessageBox.Show(msg);
}
e.Cancel = false;
}
public void AcquireFastExample(IntPtr parent)
{
TwainSession session = new TwainSession();
session.Startup(parent, "manufacturer", "productFamily", "version", "application", TwainStartupFlags.None);
session.EnableAcquireMultiPageEvent = true;
session.AcquireMultiPage += new EventHandler<TwainAcquireMultiPageEventArgs>(twain_AcquireMulti);
session.AcquireFast(Path.Combine(LEAD_VARS.ImagesDir, "Out_test.tif"),
TwainFastUserInterfaceFlags.Show,
TwainTransferMode.Buffer,
RasterImageFormat.Tif, 1, true, 0, true);
session.Shutdown();
}
static class LEAD_VARS
{
public const string ImagesDir = @"C:\LEADTOOLS23\Resources\Images";
}