Exemple #1
0
        private void btSave_Click(object sender, EventArgs e)
        {
            if (DialogResult.OK == sfdImg.ShowDialog())
            {
                String sFileName = sfdImg.FileName;
                try
                {
                    Bitmap[] bms = GenerateBitmaps();
                    for (int i = 0; i < bms.Length; i++)
                    {
                        String sFileName0 = sFileName;
                        if (i > 0)
                        {
                            int ipos = sFileName0.LastIndexOf(".");
                            if (ipos > -1)
                            {
                                String sExt = sFileName0.Substring(ipos);
                                sFileName0 = sFileName0.Substring(0, ipos) + "_" + i.ToString() + sExt;
                            }
                        }
                        bms[i].Save(sFileName0, ImageFormat.Png);

                        MyProcessHelper pPngQuant = new MyProcessHelper(Application.StartupPath + "\\pngquant\\pngquant.exe", sFileName0 + " --force --ext .png --verbose");
                        pPngQuant.DoIt();
                    }
                    SaveMySettings();
                }
                catch (Exception ex)
                {
                    //
                }
            }
        }
Exemple #2
0
 private void btSplitSave_Click(object sender, EventArgs e)
 {
     if (DialogResult.OK == sfdImg.ShowDialog())
     {
         String sFileName = sfdImg.FileName;
         try
         {
             List <String> lsFiles = new List <String>();
             Bitmap[]      bms     = GenerateSplittedBitmaps();
             for (int i = 0; i < bms.Length; i++)
             {
                 String sFileName0 = sFileName;
                 if (i > 0)
                 {
                     int ipos = sFileName0.LastIndexOf(".");
                     if (ipos > -1)
                     {
                         String sExt = sFileName0.Substring(ipos);
                         sFileName0 = sFileName0.Substring(0, ipos) + "_" + i.ToString() + sExt;
                     }
                 }
                 bms[i].Save(sFileName0, ImageFormat.Png);
                 lsFiles.Add(sFileName0);
             }
             int imax = lsFiles.Count;
             for (int i = 0; i < imax; i++)
             {
                 int    ibegin = i;
                 String s      = String.Empty;
                 for (i = ibegin; (i < imax) && (i < ibegin + 40); i++)
                 {
                     s += " " + lsFiles[i];
                 }
                 MyProcessHelper pPngQuant = new MyProcessHelper(Application.StartupPath + "\\pngquant\\pngquant.exe", s + " --force --ext .png --verbose");
                 pPngQuant.DoIt();
             }
             SaveMySettings();
         }
         catch (Exception ex)
         {
             //
         }
     }
 }