public static async Task <TiffIfd?> ReadNextIfdAsync(TiffIfd ifd, Stream stream, ByteOrder byteOrder) { if (ifd.NextIfdReference == null) { return(null); } var nextIfd = await ReadIfdAsync(ifd.NextIfdReference.Value, stream, byteOrder); return(nextIfd); }
private static Task <string> ReadStringAsync(TiffIfd ifd, ushort tag, Stream stream, ByteOrder byteOrder) { var entry = TiffReader.GetTiffIfdEntry(ifd, tag); if (entry == null) { return(Task.FromResult <string>(null)); } else { return(entry.Value.ReadStringAsync(stream, byteOrder)); } }
public static async Task <TiffIfdReference[]> ReadSubIfdReferencesAsync(TiffIfd ifd, Stream stream, ByteOrder byteOrder) { var subIfdsEntry = TiffReader.GetTiffIfdEntry(ifd, TiffTags.SubIFDs); if (subIfdsEntry != null) { return(await subIfdsEntry.Value.ReadIfdReferenceArrayAsync(stream, byteOrder)); } else { return(Array.Empty <TiffIfdReference>()); } }
public static Task <uint[]> ReadBitsPerSampleAsync(this TiffIfd ifd, Stream stream, ByteOrder byteOrder) { var entry = TiffReader.GetTiffIfdEntry(ifd, TiffTags.BitsPerSample); if (entry == null) { return(Task.FromResult(new uint[] { 1 })); } else { return(entry.Value.ReadIntegerArrayAsync(stream, byteOrder)); } }
private async static Task <Rational?> ReadRationalAsync(TiffIfd ifd, ushort tag, Stream stream, ByteOrder byteOrder) { var entry = TiffReader.GetTiffIfdEntry(ifd, tag); if (entry == null) { return(null); } else { return(await entry.Value.ReadRationalAsync(stream, byteOrder)); } }
public static double GetGrayResponseUnit(this TiffIfd ifd, ByteOrder byteOrder) { var entry = TiffReader.GetTiffIfdEntry(ifd, TiffTags.GrayResponseUnit); if (entry == null) { return(0.01); } else { var value = entry.Value.GetInteger(byteOrder); return(Math.Pow(10, -value)); } }
public async static Task <DateTimeOffset?> ReadDateTimeAsync(this TiffIfd ifd, Stream stream, ByteOrder byteOrder) { var entry = TiffReader.GetTiffIfdEntry(ifd, TiffTags.DateTime); if (entry == null) { return(null); } else { var str = await entry.Value.ReadStringAsync(stream, byteOrder); return(DateTimeOffset.ParseExact(str, "yyyy:MM:dd HH:mm:ss", CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal)); } }
public async static Task <TiffExtraSamples[]> ReadExtraSamplesAsync(this TiffIfd ifd, Stream stream, ByteOrder byteOrder) { var entry = TiffReader.GetTiffIfdEntry(ifd, TiffTags.ExtraSamples); if (entry == null) { return(new TiffExtraSamples[0]); } else { var values = await entry.Value.ReadIntegerArrayAsync(stream, byteOrder); var result = new TiffExtraSamples[values.Length]; for (int i = 0; i < values.Length; i++) { result[i] = (TiffExtraSamples)values[i]; } return(result); } }
public static Task <string> ReadCopyrightAsync(this TiffIfd ifd, Stream stream, ByteOrder byteOrder) => ReadStringAsync(ifd, TiffTags.Copyright, stream, byteOrder);
public static Task <uint[]> ReadColorMapAsync(this TiffIfd ifd, Stream stream, ByteOrder byteOrder) => ReadIntegerArrayAsync(ifd, TiffTags.ColorMap, stream, byteOrder);
public static TiffCompression GetCompression(this TiffIfd ifd, ByteOrder byteOrder) { var entry = TiffReader.GetTiffIfdEntry(ifd, TiffTags.Compression); return(entry == null ? TiffCompression.None : (TiffCompression)entry.Value.GetInteger(byteOrder)); }
public static Task <uint[]> ReadGrayResponseCurveAsync(this TiffIfd ifd, Stream stream, ByteOrder byteOrder) => ReadIntegerArrayAsync(ifd, TiffTags.GrayResponseCurve, stream, byteOrder);
public static uint GetSamplesPerPixel(this TiffIfd ifd, ByteOrder byteOrder) => GetInteger(ifd, TiffTags.SamplesPerPixel, byteOrder) ?? 1;
// Helper functions private static uint?GetInteger(TiffIfd ifd, ushort tag, ByteOrder byteOrder) { var entry = TiffReader.GetTiffIfdEntry(ifd, tag); return(entry?.GetInteger(byteOrder)); }
public static int SizeOfIfd(TiffIfd ifd) => ifd.Entries.Length * SIZEOF_IFDENTRY + 6;
public static TiffThreshholding GetThreshholding(this TiffIfd ifd, ByteOrder byteOrder) { var entry = TiffReader.GetTiffIfdEntry(ifd, TiffTags.Threshholding); return(entry == null ? TiffThreshholding.None : (TiffThreshholding)entry.Value.GetInteger(byteOrder)); }
public static Task <Rational?> ReadYResolutionAsync(this TiffIfd ifd, Stream stream, ByteOrder byteOrder) => ReadRationalAsync(ifd, TiffTags.YResolution, stream, byteOrder);
public static TiffSubfileType?GetSubfileType(this TiffIfd ifd, ByteOrder byteOrder) { var entry = TiffReader.GetTiffIfdEntry(ifd, TiffTags.SubfileType); return(entry == null ? null : (TiffSubfileType?)entry.Value.GetInteger(byteOrder)); }
public static Task <uint[]> ReadStripByteCountsAsync(this TiffIfd ifd, Stream stream, ByteOrder byteOrder) => ReadIntegerArrayAsync(ifd, TiffTags.StripByteCounts, stream, byteOrder);
public static Task <string> ReadSoftwareAsync(this TiffIfd ifd, Stream stream, ByteOrder byteOrder) => ReadStringAsync(ifd, TiffTags.Software, stream, byteOrder);
public static TiffFillOrder GetFillOrder(this TiffIfd ifd, ByteOrder byteOrder) { var entry = TiffReader.GetTiffIfdEntry(ifd, TiffTags.FillOrder); return(entry == null ? TiffFillOrder.MostSignificantBitFirst : (TiffFillOrder)entry.Value.GetInteger(byteOrder)); }
public static TiffPhotometricInterpretation?GetPhotometricInterpretation(this TiffIfd ifd, ByteOrder byteOrder) { var entry = TiffReader.GetTiffIfdEntry(ifd, TiffTags.PhotometricInterpretation); return(entry == null ? null : (TiffPhotometricInterpretation?)entry.Value.GetInteger(byteOrder)); }
public static Task <uint[]> ReadFreeOffsetsAsync(this TiffIfd ifd, Stream stream, ByteOrder byteOrder) => ReadIntegerArrayAsync(ifd, TiffTags.FreeOffsets, stream, byteOrder);
public static TiffResolutionUnit GetResolutionUnit(this TiffIfd ifd, ByteOrder byteOrder) { var entry = TiffReader.GetTiffIfdEntry(ifd, TiffTags.ResolutionUnit); return(entry == null ? TiffResolutionUnit.Inch : (TiffResolutionUnit)entry.Value.GetInteger(byteOrder)); }
public static TiffOrientation GetOrientation(this TiffIfd ifd, ByteOrder byteOrder) { var entry = TiffReader.GetTiffIfdEntry(ifd, TiffTags.Orientation); return(entry == null ? TiffOrientation.TopLeft : (TiffOrientation)entry.Value.GetInteger(byteOrder)); }
public static uint GetRowsPerStrip(this TiffIfd ifd, ByteOrder byteOrder) => GetInteger(ifd, TiffTags.RowsPerStrip, byteOrder) ?? UInt32.MaxValue;
public static TiffIfdEntry?GetTiffIfdEntry(TiffIfd ifd, ushort tag) { var entry = ifd.Entries.FirstOrDefault <TiffIfdEntry>(e => e.Tag == tag); return(entry.Tag == 0 ? (TiffIfdEntry?)null : entry); }
public static uint?GetCellWidth(this TiffIfd ifd, ByteOrder byteOrder) => GetInteger(ifd, TiffTags.CellWidth, byteOrder);
// Baseline TIFF fields public static Task <string> ReadArtistAsync(this TiffIfd ifd, Stream stream, ByteOrder byteOrder) => ReadStringAsync(ifd, TiffTags.Artist, stream, byteOrder);
public static TiffPlanarConfiguration GetPlanarConfiguration(this TiffIfd ifd, ByteOrder byteOrder) { var entry = TiffReader.GetTiffIfdEntry(ifd, TiffTags.PlanarConfiguration); return(entry == null ? TiffPlanarConfiguration.Chunky : (TiffPlanarConfiguration)entry.Value.GetInteger(byteOrder)); }