Пример #1
0
        public static string Convert(string fileName, out SwfCompilationUnit scu, out VexObject v)
        {
            v = null;
            string result = "Failed to convert.";
            FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read);
            BinaryReader br = new BinaryReader(fs);

            string name = Path.GetFileNameWithoutExtension(fileName);
            SwfReader r = new SwfReader(br.ReadBytes((int)fs.Length));
            scu = new SwfCompilationUnit(r, name);
            if (scu.IsValid)
            {
                result = "\n\n**** Converting to SwfCompilationUnit ****\n";

            #if DEBUG
                StringWriter sw = new StringWriter();
                IndentedTextWriter w = new IndentedTextWriter(sw);
                scu.Dump(w);
                Debug.WriteLine(sw.ToString());
            #endif

                result += scu.Log.ToString();

                SwfToVex s2v = new SwfToVex();
                v = s2v.Convert(scu);
                result += "\n\n**** Converting to Vex ****\n";
                result += s2v.Log.ToString();
            }
            return result;
        }
Пример #2
0
        //public static GdiForm gf;
        static void Main(string[] args)
        {
            string fileName = "test14.swf";
            if (args.Length > 0)
            {
                fileName = args[0];
            }

            FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read);
            BinaryReader br = new BinaryReader(fs);

            SwfReader r = new SwfReader(br.ReadBytes((int)fs.Length));
            SwfCompilationUnit scu = new SwfCompilationUnit(r);

            //StringWriter sw = new StringWriter();
            //IndentedTextWriter w = new IndentedTextWriter(sw);
            //scu.Dump(w);
            //Debug.WriteLine(sw.ToString());

            SwfToVex s2v = new SwfToVex();
            VexObject v = s2v.Convert(scu);

            XamlRenderer xr = new WPFRenderer();
            xr.GenerateXaml(v);

            //GdiRenderer gr = new GdiRenderer();
            //List<Bitmap> bmps = gr.GenerateBitmaps(v);
            ////gr.ExportBitmaps(bmps);

            //gf = new GdiForm(bmps);
            //Application.EnableVisualStyles();
            //Application.Run(gf);
        }
Пример #3
0
 public static VexTree ProcessSwf(SwfCompilationUnit scu)
 {
     VexTree result = null;
     if (scu.IsValid)
     {
         SwfToVex s2v = new SwfToVex();
         VexObject vo = s2v.Convert(scu);
         result = new VexTree();
         result.Convert(vo, scu);
     }
     return result;
 }
Пример #4
0
        static void Main(string[] args)
        {
            Console.WriteLine("SWF BITMAP PACKER - swf v8");
            Console.WriteLine("");

            string fileName = (args.Length < 1) ? "test.swf" : args[0];
            if (File.Exists(fileName))
            {
                fileName = Path.GetFullPath(fileName);
                Directory.SetCurrentDirectory(Path.GetDirectoryName(fileName));
                FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read);
                BinaryReader br = new BinaryReader(fs);

                string name = Path.GetFileNameWithoutExtension(fileName);
                SwfReader r = new SwfReader(br.ReadBytes((int)fs.Length));
                SwfCompilationUnit scu = new SwfCompilationUnit(r, name);
                if (scu.IsValid)
                {
                    SwfToVex s2v = new SwfToVex();
                    VexObject vo = s2v.Convert(scu);
                    Dictionary<uint, string> bitmapPaths = s2v.bitmapPaths;
                    Dictionary<uint, System.Drawing.Rectangle> rectResult = new Dictionary<uint, System.Drawing.Rectangle>();
                    UnsafeBitmap fullBitmap = BitmapPacker.PackBitmaps(bitmapPaths, rectResult);
                    foreach (var rect in rectResult)
                    {
                        Console.WriteLine("\t" + rect.Value + ",");
                    }
                    fullBitmap.Bitmap.Save("fullBitmap.png");

                    BitmapSwapper bs = new BitmapSwapper();
                    bs.Convert(scu, fullBitmap, rectResult);

                    MemoryStream ms = new MemoryStream();
                    SwfWriter swfWriter = new SwfWriter(ms);
                    scu.ToSwf(swfWriter);
                    byte[] swfBytes = swfWriter.ToArray();
                    FileStream fsw = new FileStream("result.swf", FileMode.Create, FileAccess.Write);
                    fsw.Write(swfBytes, 0, swfBytes.Length);
                    fsw.Close();
                    ms.Close();
                }
                else
                {
                    Console.WriteLine("Not a valid swf file: " + fileName);
                    Console.WriteLine("Usage: SwfBitmapPacker <filename>");
                }
            }
            else
            {
                Console.WriteLine(fileName + " does not exist.");
                Console.WriteLine("Usage: SwfBitmapPacker <filename>");
            }
        }
Пример #5
0
        public static string Convert(
			string fileName, 
			bool isSilverlight,
			out SwfCompilationUnit scu, 
			out VexObject v, 
			out string xamlFileName)
        {
            string result = "Failed to convert.";
            FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read);
            BinaryReader br = new BinaryReader(fs);

            string name = Path.GetFileNameWithoutExtension(fileName);
            SwfReader r = new SwfReader(br.ReadBytes((int)fs.Length));
            scu = new SwfCompilationUnit(r, name);
            if (scu.IsValid)
            {
                result = "\n\n**** Converting to SwfCompilationUnit ****\n";
            #if DEBUG
                    StringWriter sw = new StringWriter();
                    IndentedTextWriter w = new IndentedTextWriter(sw);
                    scu.Dump(w);
                    Debug.WriteLine(sw.ToString());
            #endif
                result += scu.Log.ToString();

                SwfToVex s2v = new SwfToVex();
                v = s2v.Convert(scu);
                result += "\n\n**** Converting to Vex ****\n";
                result += s2v.Log.ToString();

                XamlRenderer xr;
                if (isSilverlight)
                {
                    xr = new Silverlight10Renderer();
                }
                else
                {
                    xr = new WPFRenderer();
                }
                xr.GenerateXaml(v, out xamlFileName);
                result += "\n\n**** Converting to Xaml ****\n";
                result += xr.Log.ToString();
                result += "\n\nSuccess.";
            }
            else
            {
                result = "Not a valid swf file: " + fileName;
                v = null;
                xamlFileName = "";
            }
            return result;
        }
Пример #6
0
		public static V2DContentHolder SwfToV2DContent(SwfCompilationUnit scu, ContentProcessorContext context)
        {
			V2DContentHolder result = null;
            if (scu.IsValid)
            {
                SwfToVex s2v = new SwfToVex();
                VexObject vo = s2v.Convert(scu);
                VexTree vt = new VexTree();
                vt.Convert(vo, scu);
                vt.WriteToXml();

                result = vt.GetV2DContent(context);
            }
            return result;
        }
Пример #7
0
        public static string Convert(
			bool isSilverlight,
			SwfCompilationUnit scu,
			VexObject v,
			out string xamlFileName)
        {
            string result = "Failed to convert.";

            SwfToVex s2v = new SwfToVex();
            v = s2v.Convert(scu);
            result = "\n\n**** Converting to Vex ****\n";
            result += s2v.Log.ToString();

            XamlRenderer xr;
            if (isSilverlight)
            {
                xr = new Silverlight10Renderer();
            }
            else
            {
                xr = new WPFRenderer();
            }
            xr.GenerateXaml(v, out xamlFileName);
            result += "\n\n**** Converting to Xaml ****\n";
            result += xr.Log.ToString();
            result += "\n\nSuccess.";

            return result;
        }
Пример #8
0
        static void Main(string[] args)
        {
            Console.WriteLine("SWF DUMP TOOL - swf v8");
            Console.WriteLine("");
            #if !DEBUG

            if(args.Length < 1)
            {
                Console.WriteLine("");
                Console.WriteLine("Need some swf file format help? Parser tools? Generators?");
                Console.WriteLine("Just give me a shout : )   [email protected]");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine("Usage: swfdump <filename>");
                return;
            }
            #endif

            string fileName = (args.Length < 1) ? "test.swf" : args[0];
            if(File.Exists(fileName))
            {
                fileName = Path.GetFullPath(fileName);
                Directory.SetCurrentDirectory(Path.GetDirectoryName(fileName));
                FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read);
                BinaryReader br = new BinaryReader(fs);

                string name = Path.GetFileNameWithoutExtension(fileName);
                SwfReader r = new SwfReader(br.ReadBytes((int)fs.Length));
                SwfCompilationUnit scu = new SwfCompilationUnit(r, name);
                if (scu.IsValid)
                {
                    StringWriter sw = new StringWriter();
                    IndentedTextWriter w = new IndentedTextWriter(sw);
            //					scu.Dump(w);
            //					Console.WriteLine(sw.ToString());

                    SwfToVex s2v = new SwfToVex();
                    VexObject vo = s2v.Convert(scu);

                    DumpTextObject(vo);
                    //VexTo2DPhysics.VexTo2DPhysics v2dp = new VexTo2DPhysics.VexTo2DPhysics();
                    //v2dp.Convert(vo, scu);

                    Console.WriteLine("");
                    Console.WriteLine("Need some swf file format help? [email protected]");
                    Console.WriteLine("");

                    //temp
                    MemoryStream ms = new MemoryStream();
                    SwfWriter swfWriter = new SwfWriter(ms);
                    scu.Header.IsCompressed = false;
                    scu.ToSwf(swfWriter);
                    byte[] swfBytes = swfWriter.ToArray();
                    FileStream fsw = new FileStream("dump.swf", FileMode.Create, FileAccess.Write);
                    fsw.Write(swfBytes, 0, swfBytes.Length);
                    fsw.Close();
                    ms.Close();

                    //Console.ReadLine();
                }
                else
                {
                    Console.WriteLine("Not a valid swf file: " + fileName);
                    Console.WriteLine("Usage: swfdump <filename>");
                }
            }
            else
            {
                Console.WriteLine(fileName + " does not exist.");
                Console.WriteLine("Usage: swfdump <filename>");
            }
        }