/// <summary> /// Encodes the depth image using a specified encoder. /// </summary> /// <param name="depthImageEncoder">The depth image encoder to use.</param> /// <returns>A new, corresponding encoded depth image.</returns> public EncodedDepthImage Encode(IDepthImageToStreamEncoder depthImageEncoder) { var encodedDepthImage = new EncodedDepthImage(this.Width, this.Height); encodedDepthImage.EncodeFrom(this, depthImageEncoder); return(encodedDepthImage); }
/// <summary> /// Encodes the depth image using a specified encoder. /// </summary> /// <param name="depthImageEncoder">The depth image encoder to use.</param> /// <returns>A new, corresponding encoded depth image.</returns> public EncodedDepthImage Encode(IDepthImageToStreamEncoder depthImageEncoder) { var encodedDepthImage = new EncodedDepthImage(this.Width, this.Height, this.DepthValueSemantics, this.DepthValueToMetersScaleFactor); encodedDepthImage.EncodeFrom(this, depthImageEncoder); return(encodedDepthImage); }
/// <summary> /// Decodes a specified encoded depth image with a specified decoder into the current depth image. /// </summary> /// <param name="encodedDepthImage">The encoded depth image to decode.</param> /// <param name="depthImageDecoder">The depth image decoder to use.</param> /// <remarks>The depth image width, height and pixel format must match. The method should not be called concurrently.</remarks> public void DecodeFrom(EncodedDepthImage encodedDepthImage, IDepthImageFromStreamDecoder depthImageDecoder) { if (encodedDepthImage.Width != this.Width || encodedDepthImage.Height != this.Height || encodedDepthImage.PixelFormat != this.PixelFormat) { throw new InvalidOperationException("Cannot decode from an encoded depth image that has a different width, height, or pixel format."); } depthImageDecoder.DecodeFromStream(encodedDepthImage.ToStream(), this); }
/// <summary> /// Decodes a specified encoded depth image with a specified decoder into the current depth image. /// </summary> /// <param name="encodedDepthImage">The encoded depth image to decode.</param> /// <param name="depthImageDecoder">The depth image decoder to use.</param> /// <remarks>The depth image width, height and pixel format must match. The method should not be called concurrently.</remarks> public void DecodeFrom(EncodedDepthImage encodedDepthImage, IDepthImageFromStreamDecoder depthImageDecoder) { if (encodedDepthImage.Width != this.Width || encodedDepthImage.Height != this.Height || encodedDepthImage.PixelFormat != this.PixelFormat || encodedDepthImage.DepthValueSemantics != this.DepthValueSemantics || encodedDepthImage.DepthValueToMetersScaleFactor != this.DepthValueToMetersScaleFactor) { throw new InvalidOperationException("Cannot decode from an encoded depth image that has a different width, height, pixel format, depth value semantics or depth value scale factor."); } depthImageDecoder.DecodeFromStream(encodedDepthImage.ToStream(), this); }