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"); }
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); }
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); }
public void Write1Test() { var tag = GetDefineShapeTag1(); var tagWriter = new SwfTagSerializer(new SwfFile()); var tagData = tagWriter.GetTagData(tag); Assert.AreEqual(_etalon1, tagData.Data); }
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); }
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); }
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); }
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 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"); }
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(); }
protected byte[] SerializeTag(SwfFile file, SwfTagBase tag) { var tagData = new SwfTagSerializer(file).GetTagData(tag); return(tagData.Data); }
public void Write2Test() { var tag = GetDefineShapeTag2(); var tagWriter = new SwfTagSerializer(new SwfFile()); var tagData = tagWriter.GetTagData(tag); Assert.AreEqual(_etalon2, tagData.Data); }