C# 如何在WPF';s图像控制
我正在使用一个DLL,它返回一个C# 如何在WPF';s图像控制,c#,wpf,winforms,C#,Wpf,Winforms,我正在使用一个DLL,它返回一个System.Drawing.Image对象。我在winform c#中使用了该DLL,工作正常。现在,我正在升级WPF中的应用程序,并弄不清楚如何将此返回对象(System.Drawing.Image)分配给WPF中的Image控件?有什么帮助吗?怎么样 // Winforms Image we want to get the WPF Image from... System.Drawing.Image imgWinForms = WindowsImageFr
System.Drawing.Image
对象。我在winform c#中使用了该DLL,工作正常。现在,我正在升级WPF中的应用程序,并弄不清楚如何将此返回对象(System.Drawing.Image)
分配给WPF中的Image
控件?有什么帮助吗?怎么样
// Winforms Image we want to get the WPF Image from...
System.Drawing.Image imgWinForms = WindowsImageFromDLL();
// ImageSource ...
BitmapImage bi = new BitmapImage();
bi.BeginInit();
MemoryStream ms = new MemoryStream();
// Save to a memory stream...
imgWinForms.Save(ms, ImageFormat.Bmp);
// Rewind the stream...
ms.Seek(0, SeekOrigin.Begin);
// Tell the WPF image to use this stream...
bi.StreamSource = ms;
bi.EndInit();
这样,图像将不会作为文件存储在系统中。如何
// Winforms Image we want to get the WPF Image from...
System.Drawing.Image imgWinForms = WindowsImageFromDLL();
// ImageSource ...
BitmapImage bi = new BitmapImage();
bi.BeginInit();
MemoryStream ms = new MemoryStream();
// Save to a memory stream...
imgWinForms.Save(ms, ImageFormat.Bmp);
// Rewind the stream...
ms.Seek(0, SeekOrigin.Begin);
// Tell the WPF image to use this stream...
bi.StreamSource = ms;
bi.EndInit();
这样,图像将不会作为文件存储在系统中。system.Drawing.image在中不可用WPF@UzmaGelani:读取此System.Drawing.Image在中不可用WPF@UzmaGelani:读这个