コード例 #1
0
ファイル: MainWindow.xaml.cs プロジェクト: mtratsiuk/Labs
        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);
            }
        }
コード例 #2
0
 /// <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);
         }
     }
 }
コード例 #3
0
 private void PicBox_ModIcon_MouseDoubleClick(object sender, MouseEventArgs e)
 {
     ImageActions.Load(this.PicBox_ModIcon);
 }
コード例 #4
0
 private void PicBox_GUIMedium_MouseDoubleClick(object sender, MouseEventArgs e)
 {
     ImageActions.Load(this.PicBox_GUIMedium);
 }
コード例 #5
0
        /// <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);
        }
コード例 #6
0
        /// <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));
        }