我有一个 System.Drawing.Image 的实例。
如何在我的 WPF 应用程序中显示这一点?
我尝试过img.Source
但这不起作用。
我有同样的问题并通过结合多个答案来解决它。
System.Drawing.Bitmap bmp;
Image image;
...
using (var ms = new MemoryStream())
{
bmp.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
ms.Position = 0;
var bi = new BitmapImage();
bi.BeginInit();
bi.CacheOption = BitmapCacheOption.OnLoad;
bi.StreamSource = ms;
bi.EndInit();
}
image.Source = bi;
//bmp.Dispose(); //if bmp is not used further. Thanks @Peter
From 这个问题和答案 https://stackoverflow.com/questions/94456/load-a-wpf-bitmapimage-from-a-system-drawing-bitmap
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)