Kinect虚拟试衣间开发(1)-显示colorFrame图像

时间:2024-10-09 10:50:49
private void Reader_multiSourceFrameArrived(object sender, MultiSourceFrameArrivedEventArgs e) { multiSourceFrame = e.FrameReference.AcquireFrame(); using (ColorFrame colorFrame = multiSourceFrame.ColorFrameReference.AcquireFrame()) { if (colorFrame != null) { //锁一下,保存后台缓冲 this.bitmap.Lock(); //dataFrame:The pointer to the buffer to which the data will be copied. size:The size of the buffer.ColorFormat:The color format of the converted data colorFrame.CopyConvertedFrameDataToIntPtr(this.bitmap.BackBuffer, (uint)(this.colorFrameDescription.Width * this.colorFrameDescription.Height * 4), ColorImageFormat.Bgra); //重设bitmap的数据 this.bitmap.AddDirtyRect(new Int32Rect(0, 0, this.bitmap.PixelWidth, this.bitmap.PixelHeight)); //解锁 this.bitmap.Unlock(); } } }