【发布时间】:2016-06-06 22:48:55
【问题描述】:
我正在使用一些代码来显示来自摄像机的实时视频。
在 Windows 窗体 (C#) 中代码运行良好,但在 WPF 应用程序中我收到错误:
Bitmap img = (Bitmap)eventArgs.Frame.Clone();
Image.Source = img;
错误是:无法将 System.Drawing.Bitmap 转换为 System.Wondows.Media.ImageSource。所以我使用以下代码转换了位图图像:
public ImageSource imageSourceForImageControl(Bitmap BitmapImage)
{
ImageSourceConverter SourceImage = new ImageSourceConverter();
return (ImageSource)SourceImage.ConvertFrom(BitmapImage);
}
然后我得到一个 System.NullReferenceException
知道我该怎么办吗??
PS : 我是 C# 应用程序的新手
【问题讨论】:
标签: c# wpf bitmap video-streaming