コード例 #1
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;
        }
コード例 #2
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void tbar_Contrast_ValueChanged(object sender, EventArgs e)
        {
            if (m_oBitmap == null)
                return;

            // Update the associated numeric up down control if the trackbar has focus.
            if (tbar_Contrast.Focused)
                nud_Contrast.Value = tbar_Contrast.Value;

            // Apply the processing.
            using (ImageProcessing oProcessing = new ImageProcessing(m_oBitmap))
            {
                // Must call first.
                oProcessing.AdjustContrast(tbar_Contrast.Value);

                // Must call second.
                if (tbar_Brightness.Value != 0)
                    oProcessing.AdjustBrightness(tbar_Brightness.Value);

                UpdatePreview(oProcessing.GetProcessedImage());
            }
        }
コード例 #3
0
        /// <summary>
        /// iView.NET subroutine. Processes the main display image with the specified processing type.
        /// </summary>
        /// <param name="iProcessingType">Specifies the IProcessingType interface </param>
        /// <returns></returns>
        private SResult SubApplyImageProcessing(IProcessingType iProcessingType)
        {
            if (!imgbx_MainImage.IsImageLoaded)
                return SResult.NullDisplayImage;

            // Show image processing visuals.
            Cursor.Current = Cursors.WaitCursor;

            // Process the image in the main imagebox.
            using (ImageProcessing oImageProcess = new ImageProcessing(imgbx_MainImage.ImageBoxImage))
            {
                switch (iProcessingType.StructType)
                {
                    case ProcessingStructType.GreyScaleFilter:
                        oImageProcess.ApplyGreyScaleFilter();
                        break;
                    case ProcessingStructType.InvertFilter:
                        oImageProcess.ApplyInvertFilter();
                        break;
                    case ProcessingStructType.PhotoCopyFilter:
                        oImageProcess.ApplyPhotoCopyFilter();
                        break;
                    case ProcessingStructType.RotateColourFilter:
                        oImageProcess.ApplyRotateColourFilter();
                        break;
                    case ProcessingStructType.ColourFilter:
                        ColourFilterStruct ColourStruct = (ColourFilterStruct)iProcessingType;
                        oImageProcess.ApplyColourFilter(ColourStruct.Channel, ColourStruct.Value);
                        break;
                    case ProcessingStructType.Transparency:
                        TransparencyStruct TransStruct = (TransparencyStruct)iProcessingType;
                        oImageProcess.AdjustTransparency(TransStruct.Value, 255);
                        break;
                    case ProcessingStructType.Brightness:
                        BrightnessStruct BrightStruct = (BrightnessStruct)iProcessingType;
                        oImageProcess.AdjustBrightness(BrightStruct.Value);
                        break;
                    case ProcessingStructType.Contrast:
                        ContrastStruct ContStruct = (ContrastStruct)iProcessingType;
                        oImageProcess.AdjustContrast(ContStruct.Value);
                        break;
                    case ProcessingStructType.Gamma:
                        GammaStruct GammStruct = (GammaStruct)iProcessingType;
                        oImageProcess.AdjustGamma(GammStruct.Red, GammStruct.Green, GammStruct.Blue);
                        break;
                }

                // 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);

                // Update the main imagebox with the processed image.
                imgbx_MainImage.ImageBoxImage = oImageProcess.GetProcessedImage();

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

                // Reset the cursor.
                Cursor.Current = Cursors.Default;
            }

            return SResult.Completed;
        }