Accusoft.TwainPro9.Net
Multiple Image Acquisition

The StartSession method is all that’s needed to start a multiple image session. After calling the StartSession, the Scanning event will fire when images are ready to be transferred. The PendingTransfers property of the ScanningEventArgs will contain the number of images the Data Source has ready for transfer to TwainPRO™. When the transfer is complete, TwainPRO raises the Scanned event.
 
After each complete transfer, the ScannedImage property of the ScannedEventArgs contains new image data. Save the image data to a file using the SaveFile method of the ScannedImage. To move the data to an ImagXpress® control, use the ToHdib method of ScannedImage to access the handle to the DIB and pass it to the ImagXpress FromHdib method.

C# Example
Copy Code
// This code demonstrates how to pass the scanned image from TwainPRO to ImagXpress
 
public void twainDevice_Scanned(object sender, Accusoft.TwainProSdk.ScannedEventArgs e)
{
 try
 {
  imageXView1.Image = Accusoft.ImagXpressSdk.ImageX.FromHdib(imagXpress1, e.ScannedImage.ToHdib(), true);
 }
 catch (Accusoft.TwainProSdk.TwainProException ex)
 {
  ErrorLabel.Text = ex.Message;
 }
}


You may also move the data to the Window's Clipboard with the CutToClipboard or CopyToClipboard method of the ScannedImage
Each Scanned event will change the image data. Image data from a previous acquire will be lost after each image transfer.
 
Check the PendingTransfers property in the Scanning or Scanned event to see if there are more images to acquire. A value of -1 for PendingTransfers means the Data Source does not know how many images there are. TWAIN Data Sources with Automatic Document Feeders (ADF) will return PendingTransfers equal to -1. Such devices will transfer images until the feeder is empty.
 
You can cancel a multiple image acquire by setting the Cancel parameter to True in either the Scanning or Scanned events. This will cancel all pending transfers and end the session. 

C# Example
Copy Code
// This code demonstrates how to start a TWAIN session and save each scanned image until there are no pending transfers from the Data Source
 
private void cmdScanWith_Click(object sender, EventArgs e)
{
 scanCount = 0;
 twainDevice.StartSession();
}
 
public void twainDevice_Scanned(object sender, Accusoft.TwainProSdk.ScannedEventArgs e)
{
 try
 {
  pictureBox1.Image = e.ScannedImage.SaveFile("c:\\ScannedImage" + scanCount.ToString() + ".tiff");
  scanCount++;
 }
 catch (Accusoft.TwainProSdk.TwainProException ex)
 {
  ErrorLabel.Text = ex.Message;
 }
}

 

See Also

 

 


©2016. Accusoft Corporation. All Rights Reserved.

Send Feedback