How to Display a Bitmap in a WPF Image [duplicate]
I have used this snipped now to convert the Bitmap to a ImageSource:
BitmapImage BitmapToImageSource(Bitmap bitmap){ using (MemoryStream memory = new MemoryStream()) { bitmap.Save(memory, System.Drawing.Imaging.ImageFormat.Bmp); memory.Position = 0; BitmapImage bitmapimage = new BitmapImage(); bitmapimage.BeginInit(); bitmapimage.StreamSource = memory; bitmapimage.CacheOption = BitmapCacheOption.OnLoad; bitmapimage.EndInit(); return bitmapimage; }}
This should do:
ImageSource imgSource = new BitmapImage(new Uri("HERE GOES YOUR URI"));image1.Source = imgSource; //image1 is your control
If you need the Bitmap class try using this:
public ImageSource imageSourceForImageControl(Bitmap yourBitmap){ ImageSourceConverter c = new ImageSourceConverter(); return (ImageSource)c.ConvertFrom(yourBitmap);}