c# - 使用 WIA 自动化扫描多页

标签 c# scanning wia

<分区>

我正在尝试使用 WIA Automation,但我很难一次扫描多页。谁能给我一些关于如何实现这一目标的提示?下面是我用来扫描文档/图像的代码示例:

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;
}

最佳答案

所以你说的好像是 C#。

查看此答案:Using C#/WIA version 2.0 on Vista to Scan

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

关于c# - 使用 WIA 自动化扫描多页,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5076575/

相关文章:

c# - C#中的自顶向下解析实现

c# - UserManager.Create : An exception of type 'System.MissingMethodException' occurred in mscorlib. dll 但未在用户代码中处理

java - Alfresco 社区版中的扫描功能?

java - 缓冲图像颜色饱和度

python - 矩阵上的 tensorflow 扫描

c# - 如何在 C#.NET 的 DataGridView 中允许 CRUD 操作?

c# - 使用 SQL 命令从数据库读取最后插入的 UID

c# - 如何从浏览器应用程序控制扫描仪?

c# - 通过 Feeder 进行 WIA 扫描

c# - WIA 常量和值的 Intellisense/文档