当前位置: 首页>>代码示例>>C#>>正文


C# SwfWriter.ToArray方法代码示例

本文整理汇总了C#中DDW.Swf.SwfWriter.ToArray方法的典型用法代码示例。如果您正苦于以下问题:C# SwfWriter.ToArray方法的具体用法?C# SwfWriter.ToArray怎么用?C# SwfWriter.ToArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DDW.Swf.SwfWriter的用法示例。


在下文中一共展示了SwfWriter.ToArray方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Main

        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>");
            }
        }
开发者ID:nyxojaele,项目名称:Swf2XNA,代码行数:53,代码来源:SwfBitmapPacker.cs

示例2: Main

        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>");
            }
        }
开发者ID:Hamsand,项目名称:Swf2XNA,代码行数:72,代码来源:SwfDump.cs


注:本文中的DDW.Swf.SwfWriter.ToArray方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。