【问题标题】:WIA Duplex scanning using document feeder使用文档进纸器的 WIA 双面扫描
【发布时间】:2018-04-27 06:31:42
【问题描述】:

下面是我尝试从双面扫描仪传输图像的 C# 代码。我能够获得一张图像(仅限正面),但我无法获得第二张图像。我尝试将设备属性 3088 更改为 5,但我遇到了灾难性故障。我在 Windows 10、64 位上使用 WIA 2.0,但项目使用的是 X86。正如我在之前的问题中所读到的那样,我也尝试过两次传输图像,但出现错误。我正在使用 duplexid600 扫描仪,并且从 windows 扫描仪软件中我能够获得双面图像。下面是我的代码

 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;

            }
        }

【问题讨论】:

    标签: c# duplex wia


    【解决方案1】:

    调用这个两次,如果您将 3088 设置为 5(双面),它应该给出第二张图像。

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

    但请注意 - 在我的扫描仪上使用第二个“开始扫描”命令,您发出了一个新任务,这意味着您的扫描仪可能已经开始扫描第二个物理页面 - 同时将后台分配给您的文件。如果您知道解决方法,请告诉我!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-10-27
      • 2015-08-24
      • 2015-12-18
      • 2021-07-13
      • 2023-03-11
      • 1970-01-01
      • 2012-02-07
      • 2016-05-08
      相关资源
      最近更新 更多