示例#1
0
        /// <summary>
        /// Gets the image data for the specified plane.
        /// </summary>
        /// <param name="channel">The channel.</param>
        /// <returns>The image plane data.</returns>
        /// <exception cref="HeifException">The image does not contain the specified channel.</exception>
        /// <exception cref="ObjectDisposedException">The object has been disposed.</exception>
        public HeifPlaneData GetPlane(HeifChannel channel)
        {
            VerifyNotDisposed();

            if (!LibHeifNative.heif_image_has_channel(this.image, channel))
            {
                ExceptionUtil.ThrowHeifException(Resources.ImageDoesNotContainChannel);
            }

            int width  = LibHeifNative.heif_image_get_width(this.image, channel);
            int height = LibHeifNative.heif_image_get_height(this.image, channel);

            var scan0 = LibHeifNative.heif_image_get_plane(this.image, channel, out int stride);

            if (scan0 == IntPtr.Zero || width == -1 || height == -1)
            {
                ExceptionUtil.ThrowHeifException(Resources.ImageDoesNotContainChannel);
            }

            return(new HeifPlaneData(width, height, stride, channel, scan0));
        }