Esempio n. 1
0
 public TagBody(Tag parent)
 {
     _parent = parent;
 }
Esempio n. 2
0
        public void Read(Stream stream)
        {
            BinaryReader input = new BinaryReader(stream, Encoding.UTF8);
            MemoryStream buffer = null;

            // Part 1
            _header = new Header();
            _header.ReadExternal(input);

            if (_header.IsCompressed)
            {
                int len;
                byte[] bb = new byte[1024];

                buffer = new MemoryStream();

                /* TODO can we do something about this zlib crap? */

                ZOutputStream zo = new ZOutputStream(buffer);

            #if DEBUG
                Console.WriteLine("[i] Decompressing ...");
            #endif
                while ((len = input.Read(bb, 0, 1024)) > 0)
                {
                    // Careful ... This is getting stuck in an endless loop if Z_BEST_COMPRESSION was used when
                    // compressing the output.
                    zo.Write(bb, 0, len);
                }

            #if DEBUG
                Console.WriteLine("[+] Decompressed");
            #endif

                zo.Flush();

                input.Close();

                buffer.Seek(0, SeekOrigin.Begin);

                input = new BinaryReader(buffer, Encoding.UTF8);
            }

            // Part 2
            _frameSize = new RECT();
            _frameSize.ReadExternal(input);

            // 8.8 fixed value ??
            // TODO verify
            byte lo = input.ReadByte();
            byte hi = input.ReadByte();
            _frameRate = hi + (lo * 0.01f);

            _frameCount = input.ReadUInt16();

            _tags = new ArrayList();

            while (true)
            {
                Tag tag = new Tag(this);

                tag.ReadExternal(input);

                _tags.Add(tag);

                if (0x00 == tag.Header.Type)
                {
                    break;
                }
            }

            input.Close();

            if (null != buffer)
            {
                buffer.Close();
                buffer.Dispose();
            }
        }