Summary description for Bmp.
コード例 #1
0
ファイル: ViewPck.cs プロジェクト: ratzlaff/XCom-tools
 // saves a bitmap as a 8-bit image
 public void SaveBMP(string file, Palette pal)
 {
     Bmp.SaveBMP(file, myFile, pal, numAcross(), 1);
 }
コード例 #2
0
        private void miSaveDir_Click(object sender, EventArgs e)
        {
            if (_totalViewPck.Collection != null)
            {
                string fNameStart = "";
                string extStart   = "";

                if (_totalViewPck.Collection.Name.IndexOf(".") > 0)
                {
                    fNameStart = _totalViewPck.Collection.Name.Substring(0, _totalViewPck.Collection.Name.IndexOf("."));
                    extStart   = _totalViewPck.Collection.Name.Substring(_totalViewPck.Collection.Name.IndexOf(".") + 1);
                }

                saveBmpSingle.FileName = fNameStart;

                saveBmpSingle.Title = "Select directory to save images in";

                if (saveBmpSingle.ShowDialog() == DialogResult.OK)
                {
                    string path  = saveBmpSingle.FileName.Substring(0, saveBmpSingle.FileName.LastIndexOf(@"/"));
                    string file  = saveBmpSingle.FileName.Substring(saveBmpSingle.FileName.LastIndexOf(@"/") + 1);
                    string fName = file.Substring(0, file.LastIndexOf("."));
                    string ext   = file.Substring(file.LastIndexOf(".") + 1);

//					int countNum = 0;
//					int charPos = fName.Length - 1;
//					int tens = 1;
//					while (charPos >= 0 && Char.IsDigit(fName[charPos]))
//					{
//						int digit = int.Parse(fName[charPos].ToString());
//						countNum += digit*tens;
//						tens *= 10;
//						fName = fName.Substring(0, charPos--);
//					}

                    string zeros = "";
                    int    tens  = _totalViewPck.Collection.Count;
                    while (tens > 0)
                    {
                        zeros += "0";
                        tens  /= 10;
                    }

                    ProgressWindow pw = new ProgressWindow(this);
                    pw.Minimum = 0;
                    pw.Maximum = _totalViewPck.Collection.Count;
                    pw.Width   = 300;
                    pw.Height  = 50;

                    pw.Show();
                    foreach (XCImage xc in _totalViewPck.Collection)
                    {
                        //Console.WriteLine("Save to: " + path + @"\" + fName + (xc.FileNum + countNum) + "." + ext);
                        //Console.WriteLine("Save: " + path + @"\" + fName + string.Format("{0:" + zeros + "}", xc.FileNum) + "." + ext);
                        Bmp.Save(
                            path + @"/" + fName + string.Format(
                                "{0:" + zeros + "}",
                                xc.FileNum) + "." + ext,
                            xc.Image);
                        //Console.WriteLine("---");
                        pw.Value = xc.FileNum;
                    }
                    pw.Hide();
                }
            }
        }