Пример #1
0
        /// <summary>
        /// This function allocates and initializes an incremental-decoder object, which
        /// will output the RGB/A samples specified by '<paramref name="colorspace"/>' into a preallocated
        /// buffer '<paramref name="output_buffer"/>'. The size of this buffer is at least
        /// '<paramref name="output_buffer_size"/>' and the stride (distance in bytes between two scanlines)
        /// is specified by '<paramref name="output_stride"/>'
        /// </summary>
        /// <remarks>
        /// Additionally, <paramref name="output_buffer"/> can be passed NULL in which case the output
        /// buffer will be allocated automatically when the decoding starts. The
        /// '<paramref name="colorspace"/>' is taken into account for allocating this buffer. All other
        /// parameters are ignored.
        /// </remarks>
        /// <exception cref="InvalidProgramException">Unknown error occured.</exception>
        /// <exception cref="NotSupportedException"><paramref name="colorspace"/> is not RGB(A) colorspace</exception>
        /// <exception cref="ArgumentOutOfRangeException"><paramref name="colorspace"/> is not a valid value</exception>
        /// <returns><see cref="WebpImageDecoder"/></returns>
        public static WebpImageDecoder CreateDecoderForRGBX(ILibwebp library, Colorspace colorspace, IntPtr output_buffer, UIntPtr output_buffer_size, int output_stride)
        {
            WebpImageDecoder result;

            if (colorspace >= Colorspace.MODE_LAST)
            {
                throw new ArgumentOutOfRangeException(nameof(colorspace));
            }
            if (colorspace == Colorspace.MODE_YUVA || colorspace == Colorspace.MODE_YUV)
            {
                throw new NotSupportedException();
            }
            else
            {
                var ptr = library.WebPINewRGB(colorspace, output_buffer, output_buffer_size, output_stride);
                if (ptr == IntPtr.Zero)
                {
                    throw new Exception();
                }
                else
                {
                    result         = new WebpImageDecoder(library, false);
                    result.decoder = ptr;
                }
            }
            if (result == null)
            {
                throw new InvalidProgramException();
            }
            return(result);
        }
Пример #2
0
 /// <summary>
 /// This function allocates and initializes an incremental-decoder object, which
 /// will output the RGB/A samples specified by '<paramref name="colorspace"/>' into a preallocated internal buffer.
 /// </summary>
 /// <remarks>
 /// Equivalent to <seealso cref="CreateDecoderForRGBX(Colorspace, IntPtr, UIntPtr, int)"/>, with 'output_buffer' is NULL.
 /// Use <seealso cref="WebpImageDecoder.GetDecodedImage(ref int, out int, out int, out int, out IntPtr)"/> or <seealso cref="WebpImageDecoder.GetDecodedImage(ref int, out int, out int, out int, out ReadOnlySpan{byte})"/>
 /// to obtain the decoded data.
 /// </remarks>
 /// <exception cref="InvalidProgramException">Unknown error occured.</exception>
 /// <exception cref="NotSupportedException"><paramref name="colorspace"/> is not RGB(A) colorspace</exception>
 /// <exception cref="ArgumentOutOfRangeException"><paramref name="colorspace"/> is not a valid value</exception>
 /// <returns><see cref="WebpImageDecoder"/></returns>
 public WebpImageDecoder CreateDecoderForRGBX(Colorspace colorspace)
 {
     this.ThrowIfDisposed();
     return(WebpImageDecoder.CreateDecoderForRGBX(this.library, colorspace));
 }
Пример #3
0
 /// <summary>
 /// This function allocates and initializes an incremental-decoder object, which
 /// will output the RGB/A samples specified by '<paramref name="colorspace"/>' into a preallocated
 /// buffer '<paramref name="output_buffer"/>'. The size of this buffer is at least
 /// '<paramref name="output_buffer_size"/>' and the stride (distance in bytes between two scanlines)
 /// is specified by '<paramref name="output_stride"/>'
 /// </summary>
 /// <remarks>
 /// Additionally, <paramref name="output_buffer"/> can be passed NULL in which case the output
 /// buffer will be allocated automatically when the decoding starts. The
 /// '<paramref name="colorspace"/>' is taken into account for allocating this buffer. All other
 /// parameters are ignored.
 /// </remarks>
 /// <exception cref="InvalidProgramException">Unknown error occured.</exception>
 /// <exception cref="NotSupportedException"><paramref name="colorspace"/> is not RGB(A) colorspace</exception>
 /// <exception cref="ArgumentOutOfRangeException"><paramref name="colorspace"/> is not a valid value</exception>
 /// <returns><see cref="WebpImageDecoder"/></returns>
 public WebpImageDecoder CreateDecoderForRGBX(Colorspace colorspace, IntPtr output_buffer, UIntPtr output_buffer_size, int output_stride)
 {
     this.ThrowIfDisposed();
     return(WebpImageDecoder.CreateDecoderForRGBX(this.library, colorspace, output_buffer, output_buffer_size, output_stride));
 }