在WPF中使用WriteableBitmap 绑定到xaml的Image控件进行视频流的渲染,调用WritePixels方法能展示每一帧的图片,但是图像是上下颠倒的,将byte[] Data转为图片文件并没有颠倒,请问这是什么原因导致的?
public class VideoFrame
{
public long Timestamp { get; set; }
public int Width { get; set; }
public int Height { get; set; }
public int Size { get; set; }
public byte[] Data { get; set; }
}
========================================
public WriteableBitmap ImageSource
public void UpdateWriteableBitmap(VideoFrame frame)
{
if (ImageSource == null || ImageSource.Width != frame.Width || ImageSource.Height != frame.Height)
{
ImageSource = new WriteableBitmap(frame.Width, frame.Height, 96, 96, PixelFormats.Bgr32, null);
ImageSource.WritePixels(new Int32Rect(0, 0, frame.Width, frame.Height),frame.Data, ImageSource.BackBufferStride, 0);
}
else
{
ImageSource.WritePixels(new Int32Rect(0, 0, frame.Width, frame.Height),frame.Data, ImageSource.BackBufferStride, 0);
}
}