【问题标题】:WIA Scanner Large Image SizeWIA 扫描仪大图像尺寸
【发布时间】:2017-05-05 19:49:15
【问题描述】:

我正在尝试WIA 使用 C# 从扫描仪获取图像。我正在使用PictureBox 来获取图像。我能够扫描图像。但是图像尺寸太大。我如何设置图像的分辨率并将此图像显示为可以适合表单的固定大小。其中窗体 WindowState 为最大值。

我在 Button Click 上使用此代码从扫描仪获取图像。

try
{
 //get list of devices available
 List<string> devices = WIAScanner.GetDevices();

     foreach (string device in devices)
     {
         lbDevices.Items.Add(device);
     }
     //check if device is not available

    if (lbDevices.Items.Count == 0)
    {
        MessageBox.Show("Attach a Scanner Device.");
    }
    else
    {
       lbDevices.SelectedIndex = 0
    }
    //get images from scanner
    List<Image> images = WIAScanner.Scan((string)lbDevices.SelectedItem);

    foreach (Image image in images)
    {
         pic_scan.Image = image;
         pic_scan.Show();
         pic_scan.SizeMode = PictureBoxSizeMode.AutoSize;

         //save scanned image into specific folder
         image.Save(@"D:\ABC.jpeg", ImageFormat.Jpeg);
     }
}
catch (Exception exc)
{
    MessageBox.Show(exc.Message);
}

感谢您的友好回复。

【问题讨论】:

  • PictureBoxSystem.Drawing.Image 是 WinForms,而不是 WPF。确定您正确标记了您的问题?
  • @Clemens,已更正

标签: c# image winforms


【解决方案1】:

使用 PictureBoxSizeMode.Zoom 将图像正确放入 PictureBox。

pic_scan.SizeMode = PictureBoxSizeMode.Zoom;

【讨论】:

    猜你喜欢
    • 2011-05-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-01-15
    • 1970-01-01
    • 2019-06-12
    • 2015-05-02
    相关资源
    最近更新 更多