/// <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.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)));
static async Task <uint?> TransformValueTaskAsync(ValueTask <TiffValueCollection <uint> > valueTask) { TiffValueCollection <uint> result = await valueTask.ConfigureAwait(false); return(result.IsEmpty ? default(uint?) : result.GetFirstOrDefault()); }
static async Task <TiffStreamOffset> TransformValueTaskAsync(ValueTask <TiffValueCollection <TiffStreamOffset> > valueTask) { TiffValueCollection <TiffStreamOffset> result = await valueTask.ConfigureAwait(false); return(result.GetFirstOrDefault()); }
static async Task <TiffInkSet> TransformValueTaskAsync(ValueTask <TiffValueCollection <ushort> > valueTask) { TiffValueCollection <ushort> result = await valueTask.ConfigureAwait(false); return(result.IsEmpty ? TiffInkSet.CMYK : (TiffInkSet)result.GetFirstOrDefault()); }
/// <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)));
static async Task <TiffT4Options> TransformValueTaskAsync(ValueTask <TiffValueCollection <uint> > valueTask) { TiffValueCollection <uint> result = await valueTask.ConfigureAwait(false); return(result.IsEmpty ? TiffT4Options.None : (TiffT4Options)result.GetFirstOrDefault()); }
static async Task <TiffPredictor> TransformValueTaskAsync(ValueTask <TiffValueCollection <ushort> > valueTask) { TiffValueCollection <ushort> result = await valueTask.ConfigureAwait(false); return(result.IsEmpty ? TiffPredictor.None : (TiffPredictor)result.GetFirstOrDefault()); }