cómo asignar el objeto System.Drawing.Image en el control de imagen de WPF

I am using a DLL which is returning a System.Drawing.Image object in return. I was using that DLL in winform c# and was working fine. Now am upgrading my applicationin in WPF and confuse how can i assign this return object (System.Drawing.Image) a mi Image control in wpf ? Any help?

preguntado el 05 de mayo de 13 a las 12:05

1 Respuestas

¿Qué tal

// 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();

This way you image will not be stored as file in system.

contestado el 05 de mayo de 13 a las 12:05

System.Drawing.Image is not avaiable in WPF - DDR

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.