protected IEnumerable<TagBinaryInfo> GetTagFullBinariesFromSwfResource(string resourceName)
        {
            var file = new SwfFile();
            var stream = OpenEmbeddedResource(resourceName);
            SwfStreamReader reader = new SwfStreamReader(stream);
            file.FileInfo = reader.ReadSwfFileInfo();
            stream = DecompressIfNeeded(file.FileInfo, stream);
            stream.Seek(8, SeekOrigin.Begin);
            reader = new SwfStreamReader(stream);
            file.Header = reader.ReadSwfHeader();

            while (stream.Position < stream.Length) {
                var position = stream.Position;

                ushort typeAndSize = reader.ReadUInt16();
                SwfTagType type = (SwfTagType)(typeAndSize >> 6);
                int shortSize = typeAndSize & 0x3f;
                int size = shortSize < 0x3f ? shortSize : reader.ReadInt32();

                var length = stream.Position - position + size;

                stream.Seek(position, SeekOrigin.Begin);
                yield return new TagBinaryInfo { Type = type, Binary = reader.ReadBytes((int)length) };
            }
        }
Example #2
0
        protected IEnumerable <TagBinaryInfo> GetTagFullBinariesFromSwfResource(string resourceName)
        {
            var             file   = new SwfFile();
            var             stream = OpenEmbeddedResource(resourceName);
            SwfStreamReader reader = new SwfStreamReader(stream);

            file.FileInfo = reader.ReadSwfFileInfo();
            stream        = DecompressIfNeeded(file.FileInfo, stream);
            stream.Seek(8, SeekOrigin.Begin);
            reader      = new SwfStreamReader(stream);
            file.Header = reader.ReadSwfHeader();

            while (stream.Position < stream.Length)
            {
                var position = stream.Position;

                ushort     typeAndSize = reader.ReadUInt16();
                SwfTagType type        = (SwfTagType)(typeAndSize >> 6);
                int        shortSize   = typeAndSize & 0x3f;
                int        size        = shortSize < 0x3f ? shortSize : reader.ReadInt32();

                var length = stream.Position - position + size;

                stream.Seek(position, SeekOrigin.Begin);
                yield return(new TagBinaryInfo {
                    Type = type, Binary = reader.ReadBytes((int)length)
                });
            }
        }
Example #3
0
        public override int ReadInt32()
        {
            var a = _first.ReadInt32();
            var b = _second.ReadInt32();

            if (a != b)
            {
                throw new Exception(string.Format("a={0}, b={1}", a, b));
            }
            return(a);
        }
Example #4
0
        public static SwfTagBase Read(SwfStreamReader reader)
        {
            var type_and_size = reader.ReadUInt16();
            var tag_id        = type_and_size >> 6;
            var short_size    = type_and_size & 0x3f;
            var size          = short_size < 0x3f ? short_size : reader.ReadInt32();
            var tag_data      = reader.ReadBytes(size);

            return(Create(new SwfTagData {
                TagId = tag_id,
                TagData = tag_data
            }));
        }