我有一个位图,我想在图像控件中显示它而不保存它,我该怎么做?
最佳答案
将位图转换为 BitmapImage
并将其分配给图像控件的 Source
属性(即示例中的 CurrentImage
)到:
MemoryStream ms = new MemoryStream();
_bitmap.Save(ms, ImageFormat.Png);
ms.Position = 0;
BitmapImage bi = new BitmapImage();
bi.BeginInit();
bi.StreamSource = ms;
bi.EndInit();
CurrentImage = bi;
关于c# - 在图像控件中显示位图值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5446313/