[英]Save WriteableBitmap to file using WPF
我有:
WriteableBitmap bmp;
我基本上想将它保存到磁盘上的文件中,如下所示:
C:\bmp.png
我读了一些提到阅读的论坛:
bmp.Pixels
然后将这些像素保存到Bitmap
然后使用Bitmap.SaveImage()
函数。 但是,我无法访问任何Pixels
。 我的WriteableBitmap
显然没有任何名为Pixels
属性。
我使用.NET Framework 4.0。
使用WriteableBitmap的克隆并使用以下函数:
CreateThumbnail(filename, _frontBitmap.Clone());
...
void CreateThumbnail(string filename, BitmapSource image5)
{
if (filename != string.Empty)
{
using (FileStream stream5 = new FileStream(filename, FileMode.Create))
{
PngBitmapEncoder encoder5 = new PngBitmapEncoder();
encoder5.Frames.Add(BitmapFrame.Create(image5));
encoder5.Save(stream5);
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.