Beispiel #1
0
        public void DefineBitsJPEG2Test()
        {
            var file = new SwfFile();

            file.FileInfo.Version = 10;

            var tag = new DefineBitsJPEG2Tag();

            tag.CharacterID = 1;
            tag.ImageData   = GetEmbeddedResourceData("DefineBitsJPEG2.jpg");
            var visitor = new SwfTagSerializer(file);
            var res     = visitor.GetTagData(tag);
            var mem     = new MemoryStream();
            var writer  = new SwfStreamWriter(mem);

            writer.WriteTagData(res);

            var etalon = GetTagFullBinariesFromSwfResource("DefineBitsJPEG2.swf")
                         .FirstOrDefault(item => item.Type == SwfTagType.DefineBitsJPEG2);

            if (etalon.Binary == null)
            {
                throw new InvalidOperationException("Couldn't find etalon tag");
            }

            AssertExt.AreEqual(etalon.Binary, mem.ToArray(), "Checking DefineBitsJPEG2");
        }
Beispiel #2
0
        public void ReadTest()
        {
            var tagData   = ReadEmbeddedTagData("DefineFont3Tag.bin", SwfTagType.DefineFont3);
            var tagReader = new SwfTagDeserializer(new SwfFile());
            var tag       = tagReader.ReadTag <DefineFont3Tag>(tagData);

            Assert.IsNotNull(tag);

            Assert.AreEqual(17, tag.FontID);

            Assert.AreEqual("BlacklightD\0", tag.FontName);
            Assert.AreEqual(24, tag.Glyphs.Count);

            var secondGlyph = tag.Glyphs[1];

            Assert.AreEqual(46, secondGlyph.Code);
            Assert.AreEqual(12, secondGlyph.Records.Count);

            var lastShape = tag.Glyphs.Last();

            Assert.AreEqual(120, lastShape.Code);
            Assert.AreEqual(43, lastShape.Records.Count);

            var tagWriter      = new SwfTagSerializer(new SwfFile());
            var writtenTagData = tagWriter.GetTagData(tag);

            Assert.AreEqual(tagData.Data, writtenTagData.Data);

            Assert.IsNull(tag.RestData);
        }
Beispiel #3
0
        public void ReadTest()
        {
            var tagData = ReadEmbeddedTagData("DefineFont3Tag.bin", SwfTagType.DefineFont3);
            var tagReader = new SwfTagDeserializer(new SwfFile());
            var tag = tagReader.ReadTag<DefineFont3Tag>(tagData);
            Assert.IsNotNull(tag);

            Assert.AreEqual(17, tag.FontID);

            Assert.AreEqual("BlacklightD\0", tag.FontName);
            Assert.AreEqual(24, tag.Glyphs.Count);

            var secondGlyph = tag.Glyphs[1];
            Assert.AreEqual(46, secondGlyph.Code);
            Assert.AreEqual(12, secondGlyph.Records.Count);

            var lastShape = tag.Glyphs.Last();
            Assert.AreEqual(120, lastShape.Code);
            Assert.AreEqual(43, lastShape.Records.Count);

            var tagWriter = new SwfTagSerializer(new SwfFile());
            var writtenTagData = tagWriter.GetTagData(tag);

            Assert.AreEqual(tagData.Data, writtenTagData.Data);

            Assert.IsNull(tag.RestData);
        }
Beispiel #4
0
        public void Write1Test()
        {
            var tag       = GetDefineShapeTag1();
            var tagWriter = new SwfTagSerializer(new SwfFile());
            var tagData   = tagWriter.GetTagData(tag);

            Assert.AreEqual(_etalon1, tagData.Data);
        }
Beispiel #5
0
        public void WriteTest()
        {
            var tag = GetMetadataTag();

            var tagWriter = new SwfTagSerializer(new SwfFile());
            var tagData   = tagWriter.GetTagData(tag);

            Assert.AreEqual(_etalon, tagData.Data);
        }
        public void WriteTest()
        {
            var tag = GetSetBackgroundTag();

            var tagWriter = new SwfTagSerializer(new SwfFile());
            var tagData = tagWriter.GetTagData(tag);

            Assert.AreEqual(_etalon, tagData.Data);
        }
Beispiel #7
0
        protected string GetTagHash(SwfTagBase tag)
        {
            var file = new SwfFile();

            file.FileInfo.Version = 10;
            var ser     = new SwfTagSerializer(file);
            var tagData = ser.GetTagData(tag);

            return(GetTagHash(tagData));
        }
        public void WriteTest()
        {
            var tag = new RemoveObject2Tag {
                Depth = 0x4030
            };

            var tagWriter = new SwfTagSerializer(new SwfFile());
            var tagData = tagWriter.GetTagData(tag);

            Assert.AreEqual(_etalon, tagData.Data);
        }
Beispiel #9
0
        public void WriteTest()
        {
            var tag = new RemoveObject2Tag {
                Depth = 0x4030
            };

            var tagWriter = new SwfTagSerializer(new SwfFile());
            var tagData   = tagWriter.GetTagData(tag);

            Assert.AreEqual(_etalon, tagData.Data);
        }
Beispiel #10
0
        public void WriteTest()
        {
            var tag = new PlaceObjectTag {
                CharacterID    = 0x2010,
                Depth          = 0x4030,
                Matrix         = SwfMatrix.Identity,
                ColorTransform = new ColorTransformRGB()
            };

            var tagWriter = new SwfTagSerializer(new SwfFile());
            var tagData   = tagWriter.GetTagData(tag);

            Assert.AreEqual(_etalon, tagData.Data);
        }
Beispiel #11
0
        public void WriteTest()
        {
            var tag = new PlaceObjectTag {
                CharacterID = 0x2010,
                Depth = 0x4030,
                Matrix = SwfMatrix.Identity,
                ColorTransform = new ColorTransformRGB()
            };

            var tagWriter = new SwfTagSerializer(new SwfFile());
            var tagData = tagWriter.GetTagData(tag);

            Assert.AreEqual(_etalon, tagData.Data);
        }
        public void DefineBitsJPEG2Test()
        {
            var file = new SwfFile();
            file.FileInfo.Version = 10;

            var tag = new DefineBitsJPEG2Tag();
            tag.CharacterID = 1;
            tag.ImageData = GetEmbeddedResourceData("DefineBitsJPEG2.jpg");
            var visitor = new SwfTagSerializer(file);
            var res = visitor.GetTagData(tag);
            var mem = new MemoryStream();
            var writer = new SwfStreamWriter(mem);
            writer.WriteTagData(res);

            var etalon = GetTagFullBinariesFromSwfResource("DefineBitsJPEG2.swf")
                .FirstOrDefault(item => item.Type == SwfTagType.DefineBitsJPEG2);
            if (etalon.Binary == null) throw new InvalidOperationException("Couldn't find etalon tag");

            AssertExt.AreEqual(etalon.Binary, mem.ToArray(), "Checking DefineBitsJPEG2");
        }
Beispiel #13
0
        public void WriteTo(Stream stream, bool compress)
        {
            var outputWriter = new SwfStreamWriter(stream);

            if (compress) {
                var res = new MemoryStream();
                WriteTo(res, false);
                res.Seek(0, SeekOrigin.Begin);
                Compress(res, stream);
            } else {
                var mem = new MemoryStream();
                var writer = new SwfStreamWriter(mem);
                writer.WriteSwfHeader(Header);
                var bin = new SwfTagSerializer(this);
                foreach (var tag in Tags) {
                    var tagData = bin.GetTagData(tag);
                    writer.WriteTagData(tagData);
                }
                mem.Seek(0, SeekOrigin.Begin);

                outputWriter.WriteSwfFileInfo(new SwfFileInfo {
                    Format = "FWS",
                    FileLength = (uint)(mem.Length + 8),
                    Version = FileInfo.Version
                });
                mem.WriteTo(stream);
            }
            outputWriter.Flush();
            stream.Flush();
        }
Beispiel #14
0
        protected byte[] SerializeTag(SwfFile file, SwfTagBase tag)
        {
            var tagData = new SwfTagSerializer(file).GetTagData(tag);

            return(tagData.Data);
        }
Beispiel #15
0
        public void Write2Test()
        {
            var tag = GetDefineShapeTag2();
            var tagWriter = new SwfTagSerializer(new SwfFile());
            var tagData = tagWriter.GetTagData(tag);

            Assert.AreEqual(_etalon2, tagData.Data);
        }