/// <summary>
        /// Converts a color frame to a System.Media.ImageSource with its background removed.
        /// </summary>
        /// <param name="frame">A BackgroundRemovedColorFrame generated from a Kinect sensor.</param>
        /// <param name="format">The pixel format.</param>
        /// <returns>The specified frame in a System.media.ImageSource format.</returns>
        public static ImageSource ToBitmap(this BackgroundRemovedColorFrame frame, System.Windows.Media.PixelFormat format)
        {
            byte[] pixels = new byte[frame.PixelDataLength];
            frame.CopyPixelDataTo(pixels);

            return(pixels.ToBitmap(frame.Width, frame.Height, format));
        }