コード例 #1
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void tbar_Noise_ValueChanged(object sender, EventArgs e)
        {
            // Update the associated numeric up down control if the trackbar has focus.
            if (tbar_Noise.Focused)
                nud_Noise.Value = tbar_Noise.Value;

            // Apply the processing.
            using (ImageProcessing oProcessing = new ImageProcessing(m_oBitmap))
            {
                oProcessing.ApplyNoiseFilter(tbar_Noise.Value);
                UpdatePreview(oProcessing.GetProcessedImage());
            }
        }
コード例 #2
0
        /// <summary>
        /// iView.NET subroutine. Shows the processing editor dialog. Allows the user to specifiy the settings
        /// and preview the changes when apply a filter.
        /// </summary>
        /// <param name="nControlSet">Specifies the control set to load when the dialog has been initialized.</param>
        /// <returns></returns>
        private SResult SubShowProcessingEditor(ControlSet nControlSet)
        {
            Image oImage = imgbx_MainImage.ImageBoxImage;

            if (oImage == null)
                return SResult.NullDisplayImage;

            using (ProcessingDialog oForm = new ProcessingDialog(oImage, nControlSet))
            {
                if (oForm.ShowDialog(this) == DialogResult.OK)
                {
                    Cursor.Current = Cursors.WaitCursor;

                    using (ImageProcessing oProcessing = new ImageProcessing(oImage))
                    {
                        // Update the image edited status.
                        ImageHasBeenEdited = true;

                        // No elements in the list? Save the original state first.
                        if (m_oUndoRedo.Count == 0)
                            m_oUndoRedo.Add(imgbx_MainImage.ImageBoxImage);

                        switch (nControlSet)
                        {
                            case ControlSet.BrightnessContrast:
                                if (oForm.Contrast != 0) oProcessing.AdjustContrast(oForm.Contrast);
                                if (oForm.Brightness != 0) oProcessing.AdjustBrightness(oForm.Brightness);
                                break;
                            case ControlSet.ColourBalance:
                                oProcessing.AdjustColour(oForm.Red, oForm.Green, oForm.Blue);
                                break;
                            case ControlSet.Gamma:
                                oProcessing.AdjustGamma(oForm.Gamma, oForm.Gamma, oForm.Gamma);
                                break;
                            case ControlSet.Transparency:
                                oProcessing.AdjustTransparency(oForm.Transparency, oForm.Threshold);
                                break;
                            case ControlSet.Noise:
                                oProcessing.ApplyNoiseFilter(oForm.Noise);
                                break;
                        }

                        // Update the main image.
                        imgbx_MainImage.ImageBoxImage = oProcessing.GetProcessedImage();

                        // Save the current image state.
                        m_oUndoRedo.Add(imgbx_MainImage.ImageBoxImage);
                    }

                    Cursor.Current = Cursors.Default;

                    return SResult.Completed;
                }
            }

            return SResult.Canceled;
        }