public ProcessedPlayerDepthFrame(short[] shorts) { this.PlayerDepths = new PlayerDepth[shorts.Length]; for (int i = 0; i < shorts.Length; i++) { short val = shorts[i]; PlayerDepth pd = new PlayerDepth(val); this.PlayerDepths[i] = pd; } }
private Byte[] GenerateColoredBytes(PlayerDepth[] depths, int height, int width) { Byte[] pixels = new Byte[height * width * 4]; const Int32 BlueIndex = 0; const Int32 GreenIndex = 1; const Int32 RedIndex = 2; for (Int32 depthIndex = 0, colorIndex = 0; depthIndex < depths.Length && colorIndex < pixels.Length; depthIndex++, colorIndex += 4) { PlayerDepth pd = depths[depthIndex]; Byte intensity = CalculateIntensityFromDepth(pd.Depth); pixels[colorIndex + BlueIndex] = intensity; pixels[colorIndex + GreenIndex] = intensity; pixels[colorIndex + RedIndex] = intensity; } return pixels; }