I'm trying to follow the following tutorial but using WPF instead of Win Forms:
WPF doesn't use PictureBox
, instead it uses Image
.
So here goes trying to load an Image
.
XAML
<Image x:Name="srcImg" Width="400" Height="300"></Image>
CS Attempt 1:
Image<Bgr, Byte> My_Image = new Image<Bgr, byte>(Openfile.FileName);
srcImg.Source = My_Image.ToBitmap();
Error Message
Cannot implicitly convert type 'System.Drawing.Bitmap'
to 'System.Windows.Media.ImageSource'
CS Attempt 2:
Image<Bgr, Byte> My_Image = new Image<Bgr, byte>(Openfile.FileName);
srcImg.Source = new BitmapImage(My_Image);
Error Message
Error 1 The best overloaded method match for 'System.Windows.Media.Imaging.BitmapImage.BitmapImage(System.Uri)' has some invalid arguments
Error 2 Argument 1: cannot convert from 'Emgu.CV.Image<Emgu.CV.Structure.Bgr,byte>' to 'System.Uri'
Any ideas what I am doing wrong?