我是 wpf 控件和框架的新手。我似乎无法保存我的图像,你能帮我吗 下面是我的代码
SaveFileDialog sfd = new SaveFileDialog();
sfd.FileName = System.IO.Path.GetFileNameWithoutExtension(newlist[currentPicture]);
Nullable<bool> result = sfd.ShowDialog();
if (result == true)
{
System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(newlist[currentPicture]);
bmp.Save(newlist[currentPicture]);
}
最佳答案
对于 System.Drawing.Bitmap,您需要将对话框的 FileName 属性传递给 Save 方法。
编辑:在 WPF 中:
var encoder = new PngBitmapEncoder()
encoder.Frames.Add(BitmapFrame.Create(image));
using (var stream = dialog.OpenFile())
encoder.Save(stream);
关于c# - 如何在 WPF 中将图像保存到文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4383294/