1

Below is my c# code trying to transfer image from the duplex scanner. I'm able to acquire one image (Front Only) but i cant get the second image. I have tried changing the device property 3088 to 5 but i get a catastrophic failure. I'm working with WIA 2.0 on windows 10, 64 bit but project is using X86. I have also tried to transfer the image twice as i have read in previous questions but i get an error. I'm using duplexid600 scanner and from the windows scanner software i'm able to get a duplex image. Below is my code

 CommonDialogClass commonDialogClass = new CommonDialogClass();
        Device scannerDevice = commonDialogClass.ShowSelectDevice(WiaDeviceType.ScannerDeviceType, false, false);
        if (scannerDevice != null)
        {
            Item scannnerItem = scannerDevice.Items[1];
             //object value;

           // AdjustScannerSettings(scannnerItem, 300, 0, 0, 1010, 620, 0, 0);

           // object kuku;
           // kuku = scannerDevice.Properties["Document Handling Select"].get_Value();

            scannerDevice.Properties["Document Handling Select"].set_Value(1);//3088

           // kuku = scannerDevice.Properties["Document Handling Select"].get_Value();

            scannerDevice.Properties["Pages"].set_Value(1);//3096


           // object scanResult = commonDialogClass.ShowTransfer(scannnerItem, WIA.FormatID.wiaFormatTIFF, false);
            object scanResult = scannnerItem.Transfer(WIA.FormatID.wiaFormatBMP);
            //object scanResult1 = scannnerItem.Transfer(WIA.FormatID.wiaFormatTIFF);

            if (scanResult != null)
            {
                ImageFile image = (ImageFile) scanResult;
               // string fileName = Path.GetTempPath() + DateTime.Now.ToString("dd-MM-yyyy-hh-mm-ss-fffffff") + ".tif";


                var imageBytes = (byte[])image.FileData.get_BinaryData();
                var ms = new MemoryStream(imageBytes);
                var img = Image.FromStream(ms);

                 //int pageCount = 0;
                 //Image Tiff = img;
                 //pageCount = Tiff.GetFrameCount(FrameDimension.Page);
                 // Tiff.Dispose();


                // SaveImageToPNGFile(image, fileName);
                pictureBoxScannedImage.Image = img;

            }
        }

1 Answers1

0

Call this one twice, it should give the 2nd image if you have 3088 set to 5 (duplex).

   object scanResult = scannnerItem.Transfer(WIA.FormatID.wiaFormatBMP);
   object scanResultbacksite = scannnerItem.Transfer(WIA.FormatID.wiaFormatBMP);

Beware though - on my scanner with the 2nd "start scan" command, you issue a new task, meaning your scanner could start to scan the 2nd physical page already - while assigning the backpage to your file. If you know a solution to this, tell me please!

Cedrik
  • 1
  • 1