コード例 #1
0
        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);
        }
コード例 #2
0
        public static async Task <ImageFileHeader> LoadFromStream(Stream stream)
        {
            var ifh = new ImageFileHeader();

            var TIFFBOM = new byte[2];
            await stream.ReadAsync(TIFFBOM, 0, 2);

            var BOMValue = System.Text.Encoding.ASCII.GetString(TIFFBOM);

            ifh.IsLittleEndian = BOMValue == "II";

            var binaryReader = new BinaryTools.BinaryReader(stream, ifh.IsLittleEndian);
            await binaryReader.ReadUInt16Async(); // dispose 42

            ifh.OffsetOf1stIFD = await binaryReader.ReadUInt32Async();

            return(ifh);
        }