/// <summary>
 /// Decode the image into the specified SixLabors.ImageSharp image buffer.
 /// </summary>
 /// <param name="decoder">The decoder instance.</param>
 /// <param name="offset">Number of columns and rows to skip in the source image.</param>
 /// <param name="destinationImage">The destination image to write pixels into.</param>
 public static void Decode(this TiffImageDecoder decoder, TiffPoint offset, Image destinationImage)
 {
     if (decoder is null)
     {
         throw new ArgumentNullException(nameof(decoder));
     }
     if (destinationImage is null)
     {
         throw new ArgumentNullException(nameof(destinationImage));
     }
     Decode(decoder, offset, new TiffSize(destinationImage.Width, destinationImage.Height), default, destinationImage);
        /// <summary>
        /// Decode the image into the specified pixel buffer.
        /// </summary>
        /// <typeparam name="TPixel">The pixel type.</typeparam>
        /// <param name="decoder">The image decoder.</param>
        /// <param name="buffer">The pixel buffer to write pixels into.</param>
        public static void Decode <TPixel>(this TiffImageDecoder decoder, TiffPixelBuffer <TPixel> buffer) where TPixel : unmanaged
        {
            if (decoder is null)
            {
                throw new ArgumentNullException(nameof(decoder));
            }
            if (buffer.IsEmpty)
            {
                return;
            }

            ITiffPixelBuffer <TPixel> innerBuffer = TiffPixelBufferUnsafeMarshal.GetBuffer(buffer, out TiffPoint offset, out TiffSize size);

            decoder.Decode(default, size, offset, innerBuffer);
Exemple #3
0
        /// <summary>
        /// Decode the image into the specified pixel buffer.
        /// </summary>
        /// <typeparam name="TPixel">The pixel type.</typeparam>
        /// <param name="decoder">The image decoder.</param>
        /// <param name="buffer">The pixel buffer to write pixels into.</param>
        /// <param name="cancellationToken">The <see cref="CancellationToken"/> that fires if the user has requested to abort the decoding pipeline.</param>
        /// <returns>A <see cref="Task"/> that completes when the image has been decoded.</returns>
        public static Task DecodeAsync <TPixel>(this TiffImageDecoder decoder, TiffPixelBuffer <TPixel> buffer, CancellationToken cancellationToken = default) where TPixel : unmanaged
        {
            if (decoder is null)
            {
                throw new ArgumentNullException(nameof(decoder));
            }
            if (buffer.IsEmpty)
            {
                return(Task.CompletedTask);
            }

            ITiffPixelBuffer <TPixel> innerBuffer = TiffPixelBufferUnsafeMarshal.GetBuffer(buffer, out TiffPoint offset, out TiffSize size);

            return(decoder.DecodeAsync(default, size, offset, innerBuffer, cancellationToken));
 /// <summary>
 /// Decode the image into the specified SixLabors.ImageSharp image buffer.
 /// </summary>
 /// <param name="decoder">The decoder instance.</param>
 /// <param name="destinationImage">The destination image to write pixels into.</param>
 public static void Decode(this TiffImageDecoder decoder, Image destinationImage)
 => Decode(decoder, default, destinationImage);