private void buttonExtract_Click(object sender, EventArgs e) { if (String.IsNullOrEmpty(fullPath)) { MessageBox.Show("You must select an image to process."); return; } string outputDirectory = this.fileDirectory; DateTime startTime; TimeSpan timeToProcess; startTime = DateTime.Now; Bitmap bitmapOriginal = new Bitmap(Bitmap.FromFile(fullPath)); FormProgress formProgress = new FormProgress(); formProgress.Show(); CenterForm(formProgress); Application.DoEvents(); //set the process bar formProgress.ProgressBar.Maximum = bitmapOriginal.Width * bitmapOriginal.Height; Bitmap bitmapProcessed = RemoveFilteringHalo(bitmapOriginal, formProgress.DoProgress); bitmapProcessed.Save(Path.Combine(outputDirectory, String.Format("FHR_{0}", fileName))); formProgress.EnableOK = true; timeToProcess = DateTime.Now.Subtract(startTime); MessageBox.Show(timeToProcess.TotalMilliseconds.ToString()); }
private void button1_Click(object sender, EventArgs e) { if (String.IsNullOrEmpty(fullPath) && mFilesToWork == null) { MessageBox.Show("You must select an image or batch folder to process."); return; } DateTime startTime = DateTime.Now; FormProgress formProgress = new FormProgress(); formProgress.Show(); CenterForm(formProgress); Application.DoEvents(); if (fullPath.Length > 0) { formProgress.ProgressBarTotal.Maximum = 1; Stream fs = new StreamReader(fullPath).BaseStream; Bitmap bitmapOriginal = new Bitmap(Bitmap.FromStream(fs)); fs.Close(); fs.Dispose(); //set the process bar formProgress.ProgressBar.Maximum = bitmapOriginal.Width * 2; ProcessImage(bitmapOriginal, this.fullPath, formProgress.DoProgress, formProgress.DoTotalProgress); } else if (mFilesToWork != null) { if (mFilesToWork.Length > 0) { formProgress.ProgressBarTotal.Maximum = mFilesToWork.Length; foreach (string pathToFile in mFilesToWork) { if (File.Exists(pathToFile)) { Stream fs = new StreamReader(pathToFile).BaseStream; Bitmap bitmapOriginal = new Bitmap(Bitmap.FromStream(fs)); fs.Close(); fs.Dispose(); //set the process bar formProgress.ProgressBar.Value = 0; formProgress.ProgressBar.Maximum = bitmapOriginal.Width * 2; ProcessImage(bitmapOriginal, pathToFile, formProgress.DoProgress, formProgress.DoTotalProgress); } else { //file must have moved, decrement the total max. formProgress.ProgressBarTotal.Maximum--; } } } else { formProgress.ProgressBar.Maximum = 1; formProgress.ProgressBar.Value = 1; formProgress.ProgressBarTotal.Maximum = 1; formProgress.ProgressBarTotal.Value = 1; MessageBox.Show("No PNG files found in the specified folder"); } } else { MessageBox.Show("Error: no image or folder to process"); } formProgress.EnableOK = true; //MessageBox.Show(DateTime.Now.Subtract(startTime).TotalMilliseconds.ToString()); }