Exemplo n.º 1
0
        /// <summary>
        /// Read the values of <see cref="TiffTag.DocumentName"/>.
        /// </summary>
        /// <param name="tagReader">The tag reader to use.</param>
        /// <param name="cancellationToken">The <see cref="CancellationToken"/> that fires if the user want to stop the current task.</param>
        /// <returns>A <see cref="ValueTask{TiffValueCollection}"/> that completes when the value of the tag is read and return the read values.</returns>
        public static ValueTask <string?> ReadDocumentNameAsync(this TiffTagReader tagReader, CancellationToken cancellationToken = default)
        {
            ValueTask <string?> valueTask = tagReader.ReadASCIIFieldFirstStringAsync(TiffTag.DocumentName, sizeLimit: -1, cancellationToken);

            if (valueTask.IsCompletedSuccessfully)
            {
                return(new ValueTask <string?>(valueTask.GetAwaiter().GetResult()));
            }

            return(new ValueTask <string?>(TransformValueTaskAsync(valueTask)));
        /// <summary>
        /// Read the values of <see cref="TiffTag.TileWidth"/>.
        /// </summary>
        /// <param name="tagReader">The tag reader to use.</param>
        /// <param name="cancellationToken">The <see cref="CancellationToken"/> that fires if the user want to stop the current task.</param>
        /// <returns>A <see cref="ValueTask{TiffValueCollection}"/> that completes when the value of the tag is read and return the read values.</returns>
        public static ValueTask <uint?> ReadTileWidthAsync(this TiffTagReader tagReader, CancellationToken cancellationToken = default)
        {
            ValueTask <TiffValueCollection <uint> > valueTask = tagReader.ReadLongFieldAsync(TiffTag.TileWidth, sizeLimit: 1, cancellationToken);

            if (valueTask.IsCompletedSuccessfully)
            {
                TiffValueCollection <uint> result = valueTask.GetAwaiter().GetResult();
                return(new ValueTask <uint?>(result.IsEmpty ? default(uint?) : result.GetFirstOrDefault()));
            }

            return(new ValueTask <uint?>(TransformValueTaskAsync(valueTask)));
Exemplo n.º 3
0
        /// <summary>
        /// Read the values of <see cref="TiffTag.ExifIfd"/>.
        /// </summary>
        /// <param name="tagReader">The tag reader to use.</param>
        /// <param name="cancellationToken">The <see cref="CancellationToken"/> that fires if the user want to stop the current task.</param>
        /// <returns>A <see cref="ValueTask{TiffValueCollection}"/> that completes when the value of the tag is read and return the read values.</returns>
        public static ValueTask <TiffStreamOffset> ReadExifIfdAsync(this TiffTagReader tagReader, CancellationToken cancellationToken = default)
        {
            ValueTask <TiffValueCollection <TiffStreamOffset> > valueTask = tagReader.ReadIFD8FieldAsync(TiffTag.ExifIfd, sizeLimit: 1, cancellationToken);

            if (valueTask.IsCompletedSuccessfully)
            {
                TiffValueCollection <TiffStreamOffset> result = valueTask.GetAwaiter().GetResult();
                return(new ValueTask <TiffStreamOffset>(result.GetFirstOrDefault()));
            }

            return(new ValueTask <TiffStreamOffset>(TransformValueTaskAsync(valueTask)));
        /// <summary>
        /// Read the values of <see cref="TiffTag.WhitePoint"/>.
        /// </summary>
        /// <param name="tagReader">The tag reader to use.</param>
        /// <param name="cancellationToken">The <see cref="CancellationToken"/> that fires if the user want to stop the current task.</param>
        /// <returns>A <see cref="ValueTask{TiffValueCollection}"/> that completes when the value of the tag is read and return the read values.</returns>
        public static ValueTask <TiffRational[]> ReadWhitePointAsync(this TiffTagReader tagReader, CancellationToken cancellationToken = default)
        {
            ValueTask <TiffValueCollection <TiffRational> > valueTask = tagReader.ReadRationalFieldAsync(TiffTag.WhitePoint, sizeLimit: -1, cancellationToken);

            if (valueTask.IsCompletedSuccessfully)
            {
                TiffValueCollection <TiffRational> result = valueTask.GetAwaiter().GetResult();
                return(new ValueTask <TiffRational[]>(result.GetOrCreateArray()));
            }

            return(new ValueTask <TiffRational[]>(TransformValueTaskAsync(valueTask)));
        /// <summary>
        /// Read the values of <see cref="TiffTag.InkSet"/>.
        /// </summary>
        /// <param name="tagReader">The tag reader to use.</param>
        /// <param name="cancellationToken">The <see cref="CancellationToken"/> that fires if the user want to stop the current task.</param>
        /// <returns>A <see cref="ValueTask{TiffValueCollection}"/> that completes when the value of the tag is read and return the read values.</returns>
        public static ValueTask <TiffInkSet> ReadInkSetAsync(this TiffTagReader tagReader, CancellationToken cancellationToken = default)
        {
            ValueTask <TiffValueCollection <ushort> > valueTask = tagReader.ReadShortFieldAsync(TiffTag.InkSet, sizeLimit: 1, cancellationToken);

            if (valueTask.IsCompletedSuccessfully)
            {
                TiffValueCollection <ushort> result = valueTask.GetAwaiter().GetResult();
                return(new ValueTask <TiffInkSet>(result.IsEmpty ? TiffInkSet.CMYK : (TiffInkSet)result.GetFirstOrDefault()));
            }

            return(new ValueTask <TiffInkSet>(TransformValueTaskAsync(valueTask)));
Exemplo n.º 6
0
        /// <summary>
        /// Read the values of <see cref="TiffTag.JPEGTables"/>.
        /// </summary>
        /// <param name="tagReader">The tag reader to use.</param>
        /// <param name="cancellationToken">The <see cref="CancellationToken"/> that fires if the user want to stop the current task.</param>
        /// <returns>A <see cref="ValueTask{TiffValueCollection}"/> that completes when the value of the tag is read and return the read values.</returns>
        public static ValueTask <byte[]> ReadJPEGTablesAsync(this TiffTagReader tagReader, CancellationToken cancellationToken = default)
        {
            ValueTask <TiffValueCollection <byte> > valueTask = tagReader.ReadByteFieldAsync(TiffTag.JPEGTables, sizeLimit: -1, cancellationToken);

            if (valueTask.IsCompletedSuccessfully)
            {
                TiffValueCollection <byte> result = valueTask.GetAwaiter().GetResult();
                return(new ValueTask <byte[]>(result.GetOrCreateArray()));
            }

            return(new ValueTask <byte[]>(TransformValueTaskAsync(valueTask)));
        /// <summary>
        /// Read the values of <see cref="TiffTag.HalftoneHints"/>.
        /// </summary>
        /// <param name="tagReader">The tag reader to use.</param>
        /// <param name="cancellationToken">The <see cref="CancellationToken"/> that fires if the user want to stop the current task.</param>
        /// <returns>A <see cref="ValueTask{TiffValueCollection}"/> that completes when the value of the tag is read and return the read values.</returns>
        public static ValueTask <ushort[]> ReadHalftoneHintsAsync(this TiffTagReader tagReader, CancellationToken cancellationToken = default)
        {
            ValueTask <TiffValueCollection <ushort> > valueTask = tagReader.ReadShortFieldAsync(TiffTag.HalftoneHints, sizeLimit: -1, cancellationToken);

            if (valueTask.IsCompletedSuccessfully)
            {
                TiffValueCollection <ushort> result = valueTask.GetAwaiter().GetResult();
                return(new ValueTask <ushort[]>(result.GetOrCreateArray()));
            }

            return(new ValueTask <ushort[]>(TransformValueTaskAsync(valueTask)));