我正在尝试遵循以下教程,但使用 WPF 而不是 Win Forms:
WPF 不使用PictureBox
,而是使用Image
.
所以这里尝试加载一个Image
.
XAML
<Image x:Name="srcImg" Width="400" Height="300"></Image>
CS 尝试 1:
Image<Bgr, Byte> My_Image = new Image<Bgr, byte>(Openfile.FileName);
srcImg.Source = My_Image.ToBitmap();
错误信息
Cannot implicitly convert type 'System.Drawing.Bitmap'
to 'System.Windows.Media.ImageSource'
CS 尝试 2:
Image<Bgr, Byte> My_Image = new Image<Bgr, byte>(Openfile.FileName);
srcImg.Source = new BitmapImage(My_Image);
错误信息
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'
任何想法我做错了什么?