我正在做 Kinect 编程,当我启用颜色流时,我定义为使用每秒 30 帧的拜耳格式 (ColorImageFormat.RawBayerResolution640x480Fps30)。
渲染图像时,我使用以下代码:
PixelFormat format = PixelFormats.Bgr32;
// Bitmap source to write to.
WriteableBitmap src = new WriteableBitmap((int)_kinectSensor.ColorStream.FrameWidth, (int)_kinectSensor.ColorStream.FrameHeight, 96, 96, format, null);
// Stride for image.
var stride = (int)_kinectSensor.ColorStream.FrameWidth * format.BitsPerPixel / 8;
// Write pixels to bitmap source.
src.WritePixels(new Int32Rect(0, 0, (int)imgPic.Width, (int)imgPic.Height), rawBayerPixels, stride, 0);
// Set XAML image source = Bitmap source.
imgPic.Source = src;
如何根据所选的 ColorImageFormat 在没有上述硬编码的情况下锻炼 PixelFormat?
提前致谢!