1

使用 C# 从佳能扫描仪获取图像。使用以下代码,它工作正常,

 public ImageFile Scan()
 {
        ImageFile image;

        try
        {
            CommonDialog dialog = new CommonDialog();

            image = dialog.ShowAcquireImage(
                    WiaDeviceType.ScannerDeviceType,
                    WiaImageIntent.ColorIntent,
                    WiaImageBias.MinimizeSize,
                    WIA.FormatID.wiaFormatJPEG, 
                    true, 
                    true, 
                    false);

            return image;
        }
        catch (COMException ex)
        {
            if (ex.ErrorCode == -2145320939)
            {
                throw new ScannerNotFoundException();
            }
            else
            {
                throw new ScannerException("COM Exception", ex);
            }
        }
  }

这会启动一个如下所示的窗口,

在此处输入图像描述

扫描工作正常。没有问题。但我想在此对话框中添加一个“预定义”矩形尺寸(纸张尺寸,如 A3、A4、A5 等)下拉列表,供用户选择合适的扫描尺寸。

如何通过 c# WIA 向此对话框添加控件?

4

1 回答 1

0

通过将所有布尔属性设置为 false。

public ImageFile Scan()
 {
        ImageFile image;

        try
        {
            CommonDialog dialog = new CommonDialog();

            image = dialog.ShowAcquireImage(
                    WiaDeviceType.ScannerDeviceType,
                    WiaImageIntent.ColorIntent,
                    WiaImageBias.MinimizeSize,
                    WIA.FormatID.wiaFormatJPEG, 
                    false, 
                    false, 
                    false);

            return image;
        }
        catch (COMException ex)
        {
            if (ex.ErrorCode == -2145320939)
            {
                throw new ScannerNotFoundException();
            }
            else
            {
                throw new ScannerException("COM Exception", ex);
            }
        }
  }
于 2020-08-05T06:58:48.660 回答