Share via


ColorImageFrame.CopyPixelDataTo Method (Byte[])

Kinect for Windows 1.5, 1.6, 1.7, 1.8

Copies a frame of color data to a pre-allocated array of bytes. The array size must be equal to the ColorImageFrame.PixelDataLength Property.

Syntax

public void CopyPixelDataTo (
         byte[] pixelData
)

Parameters

  • pixelData
    Type: Byte
    An array of bytes to receive the pixel data.

Requirements

Namespace: Microsoft.Kinect

Assembly: Microsoft.Kinect (in microsoft.kinect.dll)

See Also

Expand imageRemarks

Each pixel of color data is stored in a byte; therefore the array in this method is an array of bytes. Here's an example:

  // For color data
  //frame = ColorImageFrame
  byte[] data = new byte[frame.PixelDataLength];
  IntPtr pixelData = Marshal.AllocHGlobal(data.Length);
  try
  {
    frame.CopyPixelDataTo(pixelData, data.Length);
  }
  finally
  {
    if (pixelData != IntPtr.Zero) Marshal.FreeHGlobal(pixelData);
  }
    

Reference

ColorImageFrame Class
ColorImageFrame Members
Microsoft.Kinect Namespace