GetDepthImage() private method

private GetDepthImage ( int &size ) : IntPtr
size int
return IntPtr
    //update Depth array and texture
    private void UpdateDepth()
    {
        int size = 0;

        //copy pixel data from unmanaged memory
        IntPtr ptr = KinectWrapper.GetDepthImage(ref size);

        if (ptr != IntPtr.Zero)
        {
            Marshal.Copy(ptr, seqDepth, 0, size);

            //create depth array
            for (int x = 0; x < IM_W; x++)
            {
                for (int y = 0; y < IM_H; y++)
                {
                    depth[IM_W - x - 1][IM_H - y - 1] = BitConverter.ToInt16(seqDepth, (x * 2) + (y * IM_W * 2));
                }
            }

            if (displayDepthImage)
            {
                //create color matrix as bytes (loops resolution)
                for (int x = 0; x < IM_W; x++)
                {
                    for (int y = 0; y < IM_H; y++)
                    {
                        dcols[x + (y * IM_W)] = new Color32((byte)depth[x][y], (byte)depth[x][y], (byte)depth[x][y], 255);
                    }
                }

                //set texture
                depthImg.SetPixels32(dcols);
                depthImg.Apply();
            }
        }
    }