Example #1
0
 internal TiffImageFileDirectoryWriter(TiffFileWriter writer)
 {
     _writer  = writer;
     _entries = new List <TiffImageFileDirectoryEntry>();
 }
        /// <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));
Example #3
0
 /// <summary>
 /// Encode a single image without writing any IFD tag fields.
 /// </summary>
 /// <param name="writer">The <see cref="TiffFileWriter"/> object to write encoded image data to.</param>
 /// <param name="offset">The number of columns and rows to skip in <paramref name="reader"/>.</param>
 /// <param name="size">The number of columns and rows to encode in <paramref name="reader"/>.</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 abstract Task <TiffStreamRegion> EncodeAsync(TiffFileWriter writer, TiffPoint offset, TiffSize size, ITiffPixelBufferReader <TPixel> reader, CancellationToken cancellationToken = default);
        /// <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));