显示在WPF Drawing.Image [英] Show Drawing.Image in WPF
本文介绍了显示在WPF Drawing.Image的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
从来就得到System.Drawing.Image对象的一个实例。
I´ve got an instance of System.Drawing.Image.
我怎么能在我的WPF应用程序显示此?
How can I show this in my WPF-application?
我试着用 img.Source
但是,这并不工作。
I tried with img.Source
but that does not work.
推荐答案
我有同样的问题,并结合几个答案解决它。
I have the same problem and solve it by combining several answers.
System.Drawing.Bitmap bmp;
Image image;
...
MemoryStream ms = new MemoryStream();
bmp.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
ms.Position = 0;
BitmapImage bi = new BitmapImage();
bi.BeginInit();
bi.StreamSource = ms;
bi.EndInit();
image.Source = bi;
//bmp.Dispose(); //if bmp is not used further. Thanks @Peter
的这里抄截
这篇关于显示在WPF Drawing.Image的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文