public static async Task <TIFF> LoadFromStream(Stream stream) { var tiff = new TIFF(); tiff._ifh = await ImageFileHeader.LoadFromStream(stream); if (tiff._ifh.OffsetOf1stIFD == 0) { return(tiff); } stream.Position = tiff._ifh.OffsetOf1stIFD; while (true) { var ifd = await ImageFileDirectory.LoadFromStream(stream, tiff._ifh.IsLittleEndian); tiff.ImageFileDirectories.Add(ifd); if (ifd.OffsetOfNextIFD == 0) { break; } stream.Position = ifd.OffsetOfNextIFD; } return(tiff); }
public static async Task <ImageFileDirectory> LoadFromStream(Stream stream, bool isLitteleEndian) { var ifd = new ImageFileDirectory(); var binaryReader = new BinaryTools.BinaryReader(stream, isLitteleEndian); var count = await binaryReader.ReadUInt16Async(); for (int i = 0; i < count; ++i) { var ifdEntry = await IFDEntry.LoadFromStream(stream, isLitteleEndian); ifd.IFDEntries.Add(ifdEntry); } ifd.OffsetOfNextIFD = await binaryReader.ReadUInt32Async(); return(ifd); }