首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >扫描图像并将其保存在特定文件夹中

扫描图像并将其保存在特定文件夹中
EN

Stack Overflow用户
提问于 2013-10-01 16:54:57
回答 2查看 11.7K关注 0票数 0

我已经创建了一个Windows窗体应用程序来扫描任何图像。

扫描完成后,它会要求用户将其保存在任何文件夹中,但我希望图像保存在特定的文件夹中。

我使用的代码如下:

代码语言:javascript
复制
public class Scanner
{
    Device oDevice;
    Item oItem;
    CommonDialogClass dlg;

    public Scanner()
    {
        dlg = new CommonDialogClass();
        oDevice = dlg.ShowSelectDevice(WiaDeviceType.ScannerDeviceType, true, false);
    }

    public void Scann()
    {
        try
        {
            dlg.ShowAcquisitionWizard(oDevice);
        }
        catch (NullReferenceException ex)
        {
            MessageBox.Show(ex.Message);
        }

    }
}

private void button1_Click(object sender, EventArgs e)
{
   Scanner oScanner = new Scanner();
   oScanner.Scann();

   //Saving the image to the server directly
   button1.Text = "Image scanned";

   OpenFileDialog dlg = new OpenFileDialog();

   if (dlg.ShowDialog() == DialogResult.OK)
   {
       pictureBox1.Image = Image.FromFile(dlg.FileName);
   }            
}
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2013-10-01 17:34:06

使用CommonDialog.ShowTransfer method

示例:

代码语言:javascript
复制
Device scanner = dialog.ShowSelectDevice(WiaDeviceType.ScannerDeviceType, true, false);
Item scannnerItem = scanner.Items[1];
// TODO: Adjust scanner settings.

ImageFile scannedImage = (ImageFile)dialog.ShowTransfer(scannnerItem, WIA.FormatID.wiaFormatPNG, false);
scannedImage.SaveFile("path");
票数 0
EN

Stack Overflow用户

发布于 2015-11-19 19:42:42

你可以在wpf C#中使用扫描代码。Complete Scanning code in WPF C# using WIA, please visit this URL: http://10rem.net/blog/2010/01/08/scanning-images-in-wpf-via-wia

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/19111919

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档