使用 WIA 自动化扫描多页 [重复]

Posted

技术标签:

【中文标题】使用 WIA 自动化扫描多页 [重复]【英文标题】:Scan multiple pages using WIA automation [duplicate] 【发布时间】:2011-07-01 21:15:40 【问题描述】:

我正在使用 WIA 自动化,并且我正在努力一次扫描多个页面。谁能给我一些关于如何实现这一目标的提示?下面是我用来扫描文档/图像的代码示例:

public static byte[] ScanImage(int colourType, string formatId, int dpi)
    
      _dialog = new CommonDialogClass();
      _scanner = _dialog.ShowSelectDevice(WIA.WiaDeviceType.ScannerDeviceType, false, false);     

  foreach (Property item in _scanner.Items[1].Properties)
  
    switch (item.PropertyID)
    
      case 6146: //4 is Black-white,gray is 2, colour 1   
        SetProperty(item, colourType);
        break;
      case 6147: //dots per inch/horizontal    
        SetProperty(item, dpi);
        break;
      case 6148: //dots per inch/vertical          
        SetProperty(item, dpi);
        break;
      case 6149: //x point where to start scan   
        SetProperty(item, 0);
        break;
      case 6150: //y-point where to start scan  
        SetProperty(item, 0);
        break;
      case 6151: //horizontal extent        
        SetProperty(item, (int)(8.5 * 100));
        break;
      case 6152: //vertical extent             
        SetProperty(item, 11 * 100);
        break;
    
  

  try
  
    TempPath = System.IO.Path.GetTempPath() + "temp" + DateTime.Now.Ticks;

    ScannedImage = (ImageFile)_scanner.Items[1].Transfer(formatId);
    //System.IO.File.Delete(TempPath);
    ScannedImage.SaveFile(TempPath);

    //Convert image to binary
    Vector vector = ScannedImage.FileData;
    byte[] imgBin = (byte[])vector.get_BinaryData();
    ScannedImageBinary = (byte[])vector.get_BinaryData();

    //ImageFromFile = Image.FromFile(TempPath);
  
  catch (Exception ex)
   

  return ScannedImageBinary;

【问题讨论】:

【参考方案1】:

所以看起来像你说话的 C#。

看到这个答案:Using C#/WIA version 2.0 on Vista to Scan

我编写了一个小型库,用于在 ADF 扫描仪上扫描多个文档:http://adfwia.codeplex.com/

【讨论】:

以上是关于使用 WIA 自动化扫描多页 [重复]的主要内容,如果未能解决你的问题,请参考以下文章

使用 WIA 2.0 和 C# 扫描多页时跳过的页面

使用 WIA 或 TWAIN 扫描页面

带有自动文档进纸器 (ADF) 的 C# WIA 在某些扫描仪上仅重新调整一页

WIA:设置动态页面大小

WIA 2.0 复式属性

WIA 2.0 双面扫描