【发布时间】:2021-04-13 02:50:11
【问题描述】:
我有一个 C#/WPF 程序,它使用 EMGU 来处理 4K 视频(每个图像的图像)。我正在对图像进行一些操作,例如旋转、裁剪……这些操作很快。
我的问题是显示图像需要很长时间(40 毫秒)。如果我将我的操作添加到这个时间,我的速度将低于 20FPS。显示图像的时间为 70%。
我正在使用此代码:
<Image x:Name="VideoWidget" Stretch="Uniform"/>
if (_cameraWritableBitmap == null || _cameraWritableBitmap.PixelWidth != width || _cameraWritableBitmap.PixelHeight != height)
{
_cameraWritableBitmap = new WriteableBitmap(
width,
height,
dpiX,
dpiY,
pixelFormat,
null);
_mainWindow.VideoWidget.Source = _cameraWritableBitmap;
OnPropertyChanged("ZoomImage");
OnPropertyChanged("ZoomScreen");
OnPropertyChanged("IsZoomImageAlert");
OnPropertyChanged("IsZoomScreenAlert");
}
timePrev = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond;
_cameraWritableBitmap.Lock();
_cameraWritableBitmap.WritePixels(new Int32Rect(0, 0, width, height), imgColor.Bytes, width * 4, 0);
//Marshal.Copy(imgColor.Bytes, 0, _cameraWritableBitmap.BackBuffer, imgColor.Bytes.Length);
//_cameraWritableBitmap.AddDirtyRect(new Int32Rect(0, 0, width, height));
_cameraWritableBitmap.Unlock();
Console.WriteLine("# ECRITURE " + (DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond - timePrev));
你知道显示我的图像的最快方法吗?
谢谢,
【问题讨论】: