public void ReadWriteTest() { var file = new SwfFile { FileInfo = { Format = SwfFormat.FWS, Version = 8 }, Header = { FrameSize = new SwfRect(0, 0, 100, 100), FrameRate = 20.0, FrameCount = 1 }, Tags = { new FileAttributesTag { UseNetwork = true }, new SetBackgroundColorTag { Color = new SwfRGB(10, 224, 224) }, new PlaceObject3Tag { BackgroundColor = new SwfRGBA(255, 255, 255, 1), HasVisible = true }, new ShowFrameTag(), new EndTag() } }; var mem = new MemoryStream(); file.WriteTo(mem); mem.Seek(0, SeekOrigin.Begin); var other = SwfFile.ReadFrom(mem); Assert.AreEqual(file.Tags.Count, other.Tags.Count); }
public Stream Cycle(string path) { var facade = new SwfMillFacade(); using (var stream = File.Open(path, FileMode.Open)) { var xml = facade.ConvertToXml(SwfFile.ReadFrom(stream)); var newFile = facade.ReadFromXml(xml); var mem = new MemoryStream(); newFile.WriteTo(mem); mem.Seek(0, SeekOrigin.Begin); return(mem); } }
public void SwfToXmlTest() { var source = GetType().Assembly.GetManifestResourceStream("SwfLib.SwfMill.Tests.FlashTest.swf"); var file = SwfFile.ReadFrom(source); var doc = new SwfMillFacade().ConvertToXml(file); doc.Declaration = new XDeclaration("1", "utf-8", "yes"); var res = doc.ToString(); using (var writer = new StreamWriter(@"d:\Sergey\test.xml", false, Encoding.UTF8)) { doc.Save(writer); } }
static void SwfToXml(string[] args) { if (args.Length < 2) { Console.WriteLine("Source file wasn't specified"); ShowUsage(); return; } if (args.Length < 3) { Console.WriteLine("target file wasn't specified"); ShowUsage(); return; } using (var file = File.Open(args[1], FileMode.Open, FileAccess.Read)) { var swf = SwfFile.ReadFrom(file); var facade = new SwfMillFacade(); var doc = facade.ConvertToXml(swf); doc.Save(args[2]); } }
void ReadFile() { var swf = SwfFile.ReadFrom(m_reader.BaseStream); var tag = swf.Tags.FirstOrDefault(x => x is SymbolClassTag) as SymbolClassTag; if (tag == null) { return; } FrameRate = (uint)swf.Header.FrameRate; //Version = swf.FileInfo.Version; Version = 0; //It seem all swl have 0 for Version foreach (var reference in tag.References) { Classes.Add(reference.SymbolName); } m_reader.Seek(0, SeekOrigin.Begin); SwfData = m_reader.ReadBytes((int)m_reader.BytesAvailable); }
protected SwfFile ReadSwfFile(string resourceName) { using (var stream = OpenEmbeddedResource(resourceName)) { return(SwfFile.ReadFrom(stream)); } }