private async void ProcessImage(ImageActions action) { try { if (imgResult != null) { imgOrig = imgResult; SetImageSource(imageOriginal, imgOrig); } ToggleButtons(false); var coef = Convert.ToDouble(coefTextBox.Text); var maskType = (ExchangeMask)Enum.Parse(typeof(ExchangeMask), (string)maskTypeComboBox.SelectedItem); await Task.Run(() => { switch (action) { case ImageActions.Scale: imgResult = imgOrig.Scale(coef); break; case ImageActions.Equalize: imgResult = imgOrig.Equalize(); break; case ImageActions.Grayscale: imgResult = imgOrig.Grayscale(); break; case ImageActions.Normalize: imgResult = imgOrig.Normalize(); break; case ImageActions.DetectEdges: imgResult = imgOrig.DetectEdges(maskType); break; case ImageActions.CV: imgResult = CV.Process(imgOrig); break; } Dispatcher.Invoke(() => { SetImageSource(imageResult, imgResult); ToggleButtons(true); }); imgResult.Save("SAVED.bmp"); }); } catch (Exception ex) { MessageBox.Show($"Error: {ex.Message}"); ToggleButtons(true); } }
/// <summary> /// Load Image Button /// </summary> /// <see cref="ImageActions.LoadImage(PictureBox, out string, out int, out int, out long)"/> /// <param name="sender"></param> /// <param name="e"></param> private void btnLoadImage_Click(object sender, EventArgs e) { try { var Image = new ImageActions(); Image.LoadImage(pboxImage, out File, out Height, out Width, out Size); txtFileName.Text = File; numWidth.Value = Width; numHeight.Value = Height; txtSize.Text = Size.ToString(); } catch (Exception Error) { if (Error.Message.Contains("image format")) { MessageBox.Show("Sorry We do not support this image."); } else { MessageBox.Show("Something went wrong!!!" + "\n" + "\n" + "Image format type might not be supported." + Error); } } }
private void PicBox_ModIcon_MouseDoubleClick(object sender, MouseEventArgs e) { ImageActions.Load(this.PicBox_ModIcon); }
private void PicBox_GUIMedium_MouseDoubleClick(object sender, MouseEventArgs e) { ImageActions.Load(this.PicBox_GUIMedium); }
/// <summary> /// Save PDF as image button /// </summary> /// <see cref="ImageActions.SavePdfImage(PictureBox, string)"/> /// <param name="sender"></param> /// <param name="e"></param> private void btnSavePdfImage_Click(object sender, EventArgs e) { var Image = new ImageActions(); Image.SavePdfImage(pboxPDF, txtPDFName.Text); }
/// <summary> /// Save Image Button /// </summary> /// <see cref="ImageActions.SaveImage(PictureBox, string, string, string, int, int, int)"/> /// <param name="sender"></param> /// <param name="e"></param> private void btnSaveImage_Click(object sender, EventArgs e) { var Image = new ImageActions(); Image.SaveImage(pboxImage, lstcolorSpace.SelectedItem.ToString(), txtFileName.Text, lstFormats.SelectedItem.ToString(), Convert.ToInt32(numQuality.Value), Convert.ToInt32(numWidth.Value), Convert.ToInt32(numHeight.Value)); }