public static Bitmap ToBitmap(this Microsoft.Kinect.DepthFrame image, System.Drawing.Imaging.PixelFormat format) { if (image == null || image.FrameDescription.LengthInPixels == 0) { return(null); } ushort[] data = new ushort[image.FrameDescription.LengthInPixels]; image.CopyFrameDataToArray(data); return(data.ToBitmap(image.FrameDescription.Width, image.FrameDescription.Height, format)); }
public DepthFrame(Microsoft.Kinect.DepthFrame df) { Type = FrameType.Depth; this.underlyingDepthFrame = df; // Set Dimensions of the depth frame Width = df.DepthFrameSource.FrameDescription.Width; Height = df.DepthFrameSource.FrameDescription.Height; // Reserve memory for storing depth data if (depthData == null) { depthData = new ushort[Width * Height]; } // Copy depth data to memory reserved earlier df.CopyFrameDataToArray(this.depthData); }