private void makePhoto(object _param) { System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch(); sw.Start(); photoThreadsCounter++; photoParameters param = (photoParameters)_param; Bitmap bmp = param._frame.getFrame(param._W, param._H, grid); if (bmp == null) { return; } if (param.label != null && param.label.Length > 0) { int Frame_Width = 2 * param._W; int Frame_Height = 2 * param._H; Graphics g = Graphics.FromImage(bmp); // g.DrawString(textBox1.Text, new Font("Consolas", 10), Brushes.Gray, new PointF(0, 0)); // g.DrawString(String.Format("Pos:({0:e5};{1:e5}).Width:{2:e5}", param._frame.ctr.Real, param._frame.ctr.Imaginary, 2 * param._frame.scale), new Font("Consolas", 10), Brushes.Gray, new PointF(0, 11)); } bmp.Save(param.path, param.format); photoThreadsCounter--; statusTimeInfo = sw.ElapsedMilliseconds.ToString() + "ms"; }
private void makePhotoClick() { string path = "p.jpg"; if (this.photoSelectDestination) { sfdPhoto.Filter = getDialogFilter(photoImageFormat); if (sfdPhoto.ShowDialog() == DialogResult.OK) { path = sfdPhoto.FileName; } } else { if (!System.IO.Directory.Exists(Application.StartupPath + "\\Output")) { System.IO.Directory.CreateDirectory(Application.StartupPath + "\\Output"); } int n = 1; while (true) { path = Application.StartupPath + "\\Output\\picture" + n.ToString() + getFromatExtension(photoImageFormat); if (!System.IO.File.Exists(path)) { break; } n++; } } Frame fr = workFrame.clone(); pictureBox2.Image.Save(path); photoParameters param = new photoParameters(); param._frame = fr; param._W = photoWidth / 2; param._H = photoHeight / 2; param.path = path; param.label = photoLabel; param.format = photoImageFormat; bool separThread = true; if (!separThread) { makePhoto(param); } else { Thread t = new Thread(makePhoto); t.Start(param); } }