/// <summary> /// Encode a single image without writing any IFD tag fields. /// </summary> /// <typeparam name="TPixel">The pixel type.</typeparam> /// <param name="encoder">The image encoder.</param> /// <param name="writer">The <see cref="TiffFileWriter"/> object to write encoded image data to.</param> /// <param name="image">The image to read from.</param> /// <param name="cancellationToken">The <see cref="CancellationToken"/> that fires if the user has requested to abort the encoding pipeline.</param> /// <returns>A <see cref="Task{TiffStreamRegion}"/> that completes and return the position and length written into the stream when the image has been encoded.</returns> public static Task <TiffStreamRegion> EncodeAsync <TPixel>(this TiffImageEncoder <TPixel> encoder, TiffFileWriter writer, Image <TPixel> image, CancellationToken cancellationToken = default) where TPixel : unmanaged, IPixel <TPixel> { if (encoder is null) { throw new ArgumentNullException(nameof(encoder)); } if (writer is null) { throw new ArgumentNullException(nameof(writer)); } if (image is null) { throw new ArgumentNullException(nameof(image)); } return(encoder.EncodeAsync(writer, default, new TiffSize(image.Width, image.Height), new ImageSharpPixelBufferReader <TPixel>(image.Frames.RootFrame), cancellationToken));
/// <summary> /// Encode a single image without writing any IFD fields. /// </summary> /// <typeparam name="TPixel">The pixel type.</typeparam> /// <param name="encoder">The image encoder.</param> /// <param name="writer">The <see cref="TiffFileWriter"/> instance of the output TIFF file.</param> /// <param name="reader">The pixel buffer reader object.</param> /// <param name="cancellationToken">The <see cref="CancellationToken"/> that fires if the user has requested to abort the encoding pipeline.</param> /// <returns>A <see cref="Task{TiffStreamRegion}"/> that completes and return the position and length written into the stream when the image has been encoded.</returns> public static Task <TiffStreamRegion> EncodeAsync <TPixel>(this TiffImageEncoder <TPixel> encoder, TiffFileWriter writer, ITiffPixelBufferReader <TPixel> reader, CancellationToken cancellationToken = default) where TPixel : unmanaged { if (encoder is null) { throw new ArgumentNullException(nameof(encoder)); } if (writer is null) { throw new ArgumentNullException(nameof(writer)); } if (reader is null) { throw new ArgumentNullException(nameof(reader)); } return(encoder.EncodeAsync(writer, default, new TiffSize(reader.Width, reader.Height), reader, cancellationToken));