[英]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.