I am running into a problem scanning duplex images where occasionally, the images are being saved with one page of one image and one of another scanned image (these are scanned on a Canon dr6010c in batches)
My ImageAcquired code is below with the barcode processing in a separate thread. My question is, when duplex is enabled, are images always sent in the exact order they are scanned?
This is a head scratcher for me
Any help appreciated,
Kind Regards
Jim
Code: Select all
private void onDevice_ImageAcquired(object sender, ImageAcquiredEventArgs e)
{
try
{
Device _device = (Device)sender;
// image acquisition must be cancelled because application's form is closing
if (cancelTransferBecauseFormIsClosing)
{
// cancel image acquisition
_device.CancelTransfer();
return;
}
pageCount++;
if (imageFileName == string.Empty)
{
imageFileName = generateNewFilename();
}
AcquiredImage acquiredImage = _device.AcquiredImage;
if (_device.DocumentFeeder.DuplexEnabled)
{
if (!imageFileName.Contains("Y"))
{
imageFileName += "Y.tif";
}
acquiredImage.Save(
Path.Combine(currentScanStation.ScanFolder,
imageFileName));
//If the page count is 2 then the next image (if any) will be a new file to save
if (pageCount == 2)
{
imageFileName = string.Empty;
pageCount = 0;
currentStationScannedCount++;
}
}
else //Not a duplex scan
{
imageFileName += "N.tif";
acquiredImage.Save(
Path.Combine(currentScanStation.ScanFolder,
imageFileName));
imageFileName = string.Empty;
pageCount = 0;
currentStationScannedCount++;
}
}
catch (Exception ex)
{
MessageBox.Show("Failed to save image : " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
finally
{
updateDGVStations(currentScanStation, 1, currentStationScannedCount);
Application.DoEvents();
}
}