コード例 #1
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;
        }