如何在wpf中将图像保存在图像控件上?

时间:2021-03-17 15:50:43

I have a simple wpf application WIA.My app has an image control... I was wondering how can I save the scanned picture on my hard disk?

我有一个简单的wpf应用程序WIA.My应用程序有一个图像控件...我想知道如何将扫描的图片保存在我的硬盘上?

2 个解决方案

#1


9  

Depends on the type of the Image.Source, assuming that you have a BitmapSource as in the article it should be along those lines:

取决于Image.Source的类型,假设您在文章中有一个BitmapSource,它应该沿着这些方向:

var encoder = new PngBitmapEncoder();
encoder.Frames.Add(BitmapFrame.Create((BitmapSource)image.Source));
using (FileStream stream = new FileStream(filePath, FileMode.Create))
    encoder.Save(stream);

#2


1  

If it's a System.Drawing.Image object then just call Save?

如果它是System.Drawing.Image对象,那么只需调用Save?

#1


9  

Depends on the type of the Image.Source, assuming that you have a BitmapSource as in the article it should be along those lines:

取决于Image.Source的类型,假设您在文章中有一个BitmapSource,它应该沿着这些方向:

var encoder = new PngBitmapEncoder();
encoder.Frames.Add(BitmapFrame.Create((BitmapSource)image.Source));
using (FileStream stream = new FileStream(filePath, FileMode.Create))
    encoder.Save(stream);

#2


1  

If it's a System.Drawing.Image object then just call Save?

如果它是System.Drawing.Image对象,那么只需调用Save?