private void Save_parts_of_ckeleton(int serial) { Save_contours_Form scf = new Save_contours_Form(); scf.ShowDialog(); if (scf.DialogResult == DialogResult.OK) { string format = scf.comboBox1.Text; int size = Convert.ToInt32(scf.comboBox2.Text); string folderName = @"elements"; int files_count = 0; if (!Directory.Exists(folderName)) { System.IO.Directory.CreateDirectory(folderName); } else { files_count = Directory.GetFiles(folderName).Length; } bool result_format = true; if (format == ".jpg") { result_format = true; } else { result_format = false; } for (int i = 0; i < current_skelet_loaded.list_of_cell.Count; i++) { Bitmap bm = new Bitmap(current_skelet_loaded.Size.X, current_skelet_loaded.Size.Y); foreach (Skeleton.node sn in current_skelet_loaded.list_of_cell[i].list_of_node) { bm.SetPixel(sn.x, sn.y, Color.White); } bm = Resizez(bm); bm = CopyBitmap(bm, new Rectangle(0, 0, bm.Width, bm.Height), size); string bitmap_name = files_count++.ToString() + "_" + serial.ToString() + " " + listBox1.Items[i].ToString() + format; string pathString = System.IO.Path.Combine(folderName, bitmap_name); if (result_format) { bm.Save(pathString, ImageFormat.Jpeg); } else { bm.Save(pathString, ImageFormat.Bmp); } } } }
private void button3_Click_1(object sender, EventArgs e) { if (contours.Count != 0) { Save_contours_Form scf = new Save_contours_Form(); scf.ShowDialog(); if (scf.DialogResult == DialogResult.OK) { string format = scf.comboBox1.Text; int size = Convert.ToInt32(scf.comboBox2.Text); SaveImages(size, format); } } else { MessageBox.Show("Контуров нет! Cохранять нечего!"); } }
private void Save_parts_of_ckeleton(int serial) { Save_contours_Form scf = new Save_contours_Form(); scf.ShowDialog(); if (scf.DialogResult == DialogResult.OK) { string format = scf.comboBox1.Text; int size = Convert.ToInt32(scf.comboBox2.Text); string folderName = @"elements"; int files_count = 0; if (!Directory.Exists(folderName)) System.IO.Directory.CreateDirectory(folderName); else files_count = Directory.GetFiles(folderName).Length; bool result_format = true; if (format == ".jpg") result_format = true; else result_format = false; for (int i = 0; i < current_skelet_loaded.list_of_cell.Count; i++) { Bitmap bm = new Bitmap(current_skelet_loaded.Size.X, current_skelet_loaded.Size.Y); foreach (Skeleton.node sn in current_skelet_loaded.list_of_cell[i].list_of_node) { bm.SetPixel(sn.x, sn.y, Color.White); } bm = Resizez(bm); bm = CopyBitmap(bm, new Rectangle(0, 0, bm.Width, bm.Height),size); string bitmap_name = files_count++.ToString() + "_" + serial.ToString() + " " + listBox1.Items[i].ToString() + format; string pathString = System.IO.Path.Combine(folderName, bitmap_name); if (result_format) bm.Save(pathString, ImageFormat.Jpeg); else bm.Save(pathString, ImageFormat.Bmp); } } }