public unsafe Image ToColor(Image depthMap, Image bodyIndexMap)
        {
            if (bodyIndexMap == null || depthMap == null)
            {
                return(null);
            }

            // Object can be disposed from different thread,
            // thus it is worth to keep references to images while we're working with their buffers
            using (var bodyIndexMapCustom8Ref = bodyIndexMapCustom8.DuplicateReference())
            {
                // Custom format -> Custom8 format
                // See issue https://github.com/microsoft/Azure-Kinect-Sensor-SDK/issues/704
                Buffer.MemoryCopy(
                    bodyIndexMap.Buffer.ToPointer(), bodyIndexMapCustom8Ref.Buffer.ToPointer(),
                    bodyIndexMapCustom8Ref.SizeBytes, bodyIndexMap.SizeBytes);

                using (var transformedDepthMapRef = transformedDepthMap.DuplicateReference())
                    using (var transformedBodyIndexMapRef = transformedBodyIndexMap.DuplicateReference())
                    {
                        transformation.DepthImageToColorCameraCustom(
                            depthMap, bodyIndexMapCustom8Ref,
                            transformedDepthMapRef, transformedBodyIndexMapRef,
                            TransformationInterpolation.Nearest, BodyTracking.BodyFrame.NotABodyIndexMapPixelValue);

                        return(transformedBodyIndexMapRef.DuplicateReference());
                    }
            }
        }
        public unsafe Image ToColor(Image depthMap, Image bodyIndexMap)
        {
            if (bodyIndexMap == null || depthMap == null)
            {
                return(null);
            }

            // Object can be disposed from different thread,
            // thus it is worth to keep references to images while we're working with their buffers
            using (var transformedDepthMapRef = transformedDepthMap.DuplicateReference())
                using (var transformedBodyIndexMapRef = transformedBodyIndexMap.DuplicateReference())
                {
                    transformation.DepthImageToColorCameraCustom(
                        depthMap, bodyIndexMap,
                        transformedDepthMapRef, transformedBodyIndexMapRef,
                        TransformationInterpolation.Nearest, BodyTracking.BodyFrame.NotABodyIndexMapPixelValue);

                    return(transformedBodyIndexMapRef.DuplicateReference());
                }
        }