public void SaveBMP(string file, Palette pal, int bpp, int across) { int mod = 1; if (Size % across == 0) { mod = 0; } int space = imgSpace; Bitmap b = new Bitmap(across * (ImgWidth + space) - space, (Size / across + mod) * (ImgHeight + space) - space); Graphics g = Graphics.FromImage(b); g.FillRectangle(new SolidBrush(pal.Colors.Entries[PckImage.TransparentIndex]), 0, 0, b.Width, b.Height); for (int i = 0; i < Size; i++) { int x = i % across * (ImgWidth + space); int y = i / across * (ImgHeight + space); copy(this[i].Image, b, x, y); } b.Palette = pal.Colors; if (bpp == 8) { Bmp.Save(file, b); } else { Bmp.Save24(file, b); } }
private void viewClick(object sender, EventArgs e) { if (_totalViewPck.SelectedItems.Count == 0) { return; } var selected = _totalViewPck.SelectedItems[_totalViewPck.SelectedItems.Count - 1]; if (_totalViewPck.Collection != null) { if (_totalViewPck.Collection.IXCFile.SingleFileName != null) { string fName = _totalViewPck.Collection.Name.Substring(0, _totalViewPck.Collection.Name.IndexOf(".")); string ext = _totalViewPck.Collection.Name.Substring(_totalViewPck.Collection.Name.IndexOf(".") + 1); saveBmpSingle.FileName = fName + selected.Image.FileNum; } else { saveBmpSingle.FileName = _totalViewPck.Collection.Name + selected.Image.FileNum; } if (saveBmpSingle.ShowDialog() == DialogResult.OK) { Bmp.Save(saveBmpSingle.FileName, selected.Image.Image); } } }
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(); } } }