Пример #1
0
        static void Main(string[] args)
        {
            if (args.Length != 1 && args.Length != 2)
            {
                return;
            }

            string outdir = Path.ChangeExtension(args[0], null);

            if (!Directory.Exists(outdir))
            {
                Directory.CreateDirectory(outdir);
            }

            var Loader = new MNG();

            Loader.Load(args[0]);
            int Count = Loader.NumEmbeddedPNG;


            string TextName   = Path.ChangeExtension(args[0], ".txt");
            var    TextStream = new FileStream(TextName, FileMode.Create, FileAccess.Write);
            var    TextWriter = new StreamWriter(TextStream);

            for (int i = 0; i < Count; i++)
            {
                var bitmap = Loader.ToBitmap(i);

                var FileName = Loader.pngs[i].GetName();

                TextWriter.WriteLine(FileName);

                if (FileName != null && FileName.Length > 0 && args.Length == 2)
                {
                    bitmap.Save(Path.Combine(outdir, FileName + ".png"), System.Drawing.Imaging.ImageFormat.Png);
                }
                else
                {
                    bitmap.Save(Path.Combine(outdir, string.Format("{0:0000}.png", i)), System.Drawing.Imaging.ImageFormat.Png);
                }
            }

            TextWriter.Close();
        }
Пример #2
0
        public bool Unpack(object Args)
        {
            try
            {
                var Loader = new MNG();
                Loader.Load(m_FileName);
                int Count = Loader.NumEmbeddedPNG;

                string outdir = Path.ChangeExtension(m_FileName, null);

                for (int i = 0; i < Count; i++)
                {
                    var bitmap = Loader.ToBitmap(i);
                    bitmap.Save(Path.Combine(outdir, string.Format("{0:0000}.png", i)), System.Drawing.Imaging.ImageFormat.Png);
                }
            }
            catch (Exception E)
            {
                return(false);
            }
            return(true);
        }
Пример #3
0
 private void doLoadMNG()
 {
     dlgOpen.Filter      = "MNG|*.MNG";
     dlgSave.DefaultExt  = ".MNG";
     dlgOpen.Multiselect = false;
     if (dlgOpen.ShowDialog() == DialogResult.OK)
     {
         MNG mng = new MNG();
         if (!mng.Load(dlgOpen.FileName))
         {
             MessageBox.Show("Can not load \n" + dlgOpen.FileName, Application.ProductName);
         }
         int c = lstPictureList.Items.Count;
         for (int i = 0; i < mng.NumEmbeddedPNG; i++)
         {
             Bitmap bmp = mng.ToBitmap(i);
             Point  p   = mng.GetOffset(i);
             Animation.AddBitmap(bmp, p);
             lstPictureList.Items.Add("[" + c.ToString() + "] " + bmp.Width.ToString() + " " + bmp.Height.ToString());
             c++;
         }
     }
 }