I get this error. Here is the code:
Image image;
BitmapImage BmpImg;
MemoryStream ms;
public void Convert()
{
ms = new MemoryStream();
image.Save(ms, ImageFormat.Jpeg);
BmpImg = new BitmapImage();
BmpImg.BeginInit();
BmpImg.StreamSource = new MemoryStream(ms.ToArray());
BmpImg.EndInit();
}
private void Btn_Click(object sender, RoutedEventArgs e)
{
Dispatcher.Invoke(new Action(() => { Image.Source = BmpImg; }));
}
How to convert a System.Drawing.Image to BitmapImage and display the same on wpf?