据我了解,
void processor_NewTargetPosition(System.Drawing.Bitmap image)
{
IntPtr hBitMap = image.GetHbitmap();
BitmapSource bmaps = Imaging.CreateBitmapSourceFromHBitmap(hBitMap, IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());
bmaps.Freeze();
Dispatcher.Invoke((Action)(() =>
{
pictureBoxMain.Source = bmaps;
}), DispatcherPriority.Render, null);
}
这些代码用于将每个帧从网络摄像头放到图片框中。 此代码在WPF中运行良好。我试图转换它以窗口形式使用,但没有运气,因为我找不到这些线的替代品:
BitmapSource bmaps = Imaging.CreateBitmapSourceFromHBitmap(hBitMap, IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());
和
Dispatcher.Invoke((Action)(() =>
{
pictureBoxMain.Source = bmaps;
}), DispatcherPriority.Render, null);
有什么建议吗?谢谢。