扫描后无法在图片框控件中显示图像 [英] unable to display image in picturebox control after scanning

查看:118
本文介绍了扫描后无法在图片框控件中显示图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试开发一个桌面应用程序,如果扫描仪与电脑连接并且将显示在图片框控件中,可以扫描图像。



使用WIA dll我能够从外部设备(扫描仪)扫描图像,但它会自动保存默认图片文件夹。

任何人都可以指导我如何根据我的选择保存图片并显示该图片一个图片框。



提前谢谢。

I am trying to develop a desktop application from which image can be scanned if scanner is connected with the pc and that will display in the picturebox control.

using WIA dll i am able to scan image from an external device(scanner) but it automatically saves default picture folder.
Can anyone please guide me how to save the picture as per my choice and display that image in a picturebox.

Thanks in advance.

推荐答案

请看这里,http://channel9.msdn.com/coding4fun/articles/Look-at-me-Windows-图像采集 [ ^ ]



几乎总结了它

Please have a look here,http://channel9.msdn.com/coding4fun/articles/Look-at-me-Windows-Image-Acquisition[^]

that pretty much sums it up
tem item = device.ExecuteCommand(CommandID.wiaCommandTakePicture);
foreach (string format in item.Formats)
{
    if (format == jpegGuid)
    {
        WIA.ImageFile imagefile = item.Transfer(format) as WIA.ImageFile;
        filename = GetFreeFileName();
        if (string.IsNullOrEmpty(filename) == false)
        {
//Instead of saving  get it to the picture box (you should know how to convert it to Image object
            imagefile.SaveFile(filename);
        }
        this.picLastImage.Load(filename);
        return filename;
    }
}


private void button2_Click(object sender, EventArgs e)
{
    const string wiaFormatJPEG = "{B96B3CAE-0728-11D3-9D7B-0000F81EF32E}";
    CommonDialogClass wiaDiag = new CommonDialogClass();
    WIA.ImageFile wiaImage = null;

    wiaImage = wiaDiag.ShowAcquireImage(
            WiaDeviceType.UnspecifiedDeviceType,
            WiaImageIntent.GrayscaleIntent,
            WiaImageBias.MaximizeQuality,
            wiaFormatJPEG, true, true, false);

    WIA.Vector vector = wiaImage.FileData;

    Image i = Image.FromStream(new MemoryStream((byte[])vector.get_BinaryData()));
    i.Save(@"D:\prueba1.jpeg");
}





最终解决方案完美无缺。



Final solution works perfectly.


这篇关于扫描后无法在图片框控件中显示图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆