09/12/11

Load a WPF BitmapImage from a System.Drawing.Bitmap

 // imgLogo is WPF image so need to bind it from Bitmap or Image.
 // following code.. to bind image. try this it will work in WPF or Silverlight application
System.Drawing.Bitmap dImg = new System.Drawing.Bitmap(ApplicationVariables.TenantImage);
            MemoryStream ms = new MemoryStream();
            dImg.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);

            BitmapImage bImg = new BitmapImage();
            bImg.BeginInit();
            bImg.StreamSource = new MemoryStream(ms.ToArray());
            bImg.EndInit();
            this.imgLogo.Source = bImg;