示例#1
0
        private void ImageProcessing(int id)
        {
            if (pictureBox1.Image == null)
            {
                return;
            }
            switch (id)
            {
            case ImageProcessId.ID_ROTATE:
                RotateForm rotate = new RotateForm(curFileName);
                if (rotate.ShowDialog() == DialogResult.OK)
                {
                    int degree = rotate.getDegree;
                    curBitmap = zPhoto.TransformRotation(curBitmap, degree, 1, 0);
                }
                break;

            case ImageProcessId.ID_ZOOM:
                ZoomForm zoom = new ZoomForm();
                if (zoom.ShowDialog() == DialogResult.OK)
                {
                    float scale = zoom.getScale;
                    curBitmap = zPhoto.TransformScale(curBitmap, scale, 1, 0);
                }
                break;

            case ImageProcessId.ID_HMIRROR:
                curBitmap = zPhoto.TransformMirror(curBitmap, 4);
                break;

            case ImageProcessId.ID_VMIRROR:
                curBitmap = zPhoto.TransformMirror(curBitmap, 5);
                break;

            case ImageProcessId.ID_AUTO_COLORGRADATION:
                curBitmap = zPhoto.AutoColorGradationAdjust(curBitmap);
                break;

            case ImageProcessId.ID_AUTO_CONTRAST:
                curBitmap = zPhoto.AutoContrastAdjust(curBitmap);
                break;

            case ImageProcessId.ID_HISTAGRAMEQUALIZE:
                curBitmap = zPhoto.HistagramEqualize(curBitmap);
                break;

            case ImageProcessId.ID_BRIGHTCONTRAST:
                BrightContrastForm bc = new BrightContrastForm(curFileName);
                if (bc.ShowDialog() == DialogResult.OK)
                {
                    int bright   = bc.getBright;
                    int contrast = bc.getContrast;
                    if (bc.getVersion)
                    {
                        curBitmap = zPhoto.NLinearBrightContrastAdjust(curBitmap, bright, contrast, 128);
                    }
                    else
                    {
                        curBitmap = zPhoto.LinearBrightContrastAdjust(curBitmap, bright, contrast, 128);
                    }
                }
                break;

            case ImageProcessId.ID_COLORLEVEL:
                LevelForm form = new LevelForm(curFileName);
                if (form.ShowDialog() == DialogResult.OK)
                {
                    int    lInput  = form.getLeftInput;
                    double mInput  = form.getMidInput;
                    int    rInput  = form.getRightInput;
                    int    lOutput = form.getLeftOutput;
                    int    rOutput = form.getRightOutput;
                    int    channel = form.getChannel;
                    curBitmap = zPhoto.ColorLevelProcess(curBitmap, channel, lInput, (float)mInput, rInput, lOutput, rOutput);
                }
                break;

            case ImageProcessId.ID_HSL:
                HSLForm hsl = new HSLForm(curFileName);
                if (hsl.ShowDialog() == DialogResult.OK)
                {
                    int h = hsl.getHue;
                    int s = hsl.getSaturation;
                    int l = hsl.getLightness;
                    curBitmap = zPhoto.HueSaturationAdjust(curBitmap, h, s);
                    curBitmap = zPhoto.LightnessAdjustProcess(curBitmap, l);
                }
                break;

            case ImageProcessId.ID_COLORBALANCE:
                ColorbalanceForm corB = new ColorbalanceForm(curFileName);
                if (corB.ShowDialog() == DialogResult.OK)
                {
                    int cyan    = corB.getCyan;
                    int magenta = corB.getMagenta;
                    int yellow  = corB.getYellow;
                    curBitmap = zPhoto.ColorBalanceProcess(curBitmap, cyan, magenta, yellow, 0, corB.getLum);
                }
                break;

            case ImageProcessId.ID_INVERT:
                curBitmap = zPhoto.Invert(curBitmap);
                break;

            case ImageProcessId.ID_POSTERIZE:
                PosterizeForm poster = new PosterizeForm(curFileName);
                if (poster.ShowDialog() == DialogResult.OK)
                {
                    curBitmap = zPhoto.Posterize(curBitmap, poster.getLevelNum);
                }
                break;

            case ImageProcessId.ID_THRESHOLD:
                ThresholdForm threForm = new ThresholdForm(curFileName);
                if (threForm.ShowDialog() == DialogResult.OK)
                {
                    curBitmap = zPhoto.Threshold(curBitmap, threForm.getThresold);
                }
                break;

            case ImageProcessId.ID_DESATURATE:
                curBitmap = zPhoto.Desaturate(curBitmap);
                break;

            case ImageProcessId.ID_HIGHLIGHTSHADOW:
                HighlightShadowForm hsform = new HighlightShadowForm(curFileName);
                if (hsform.ShowDialog() == DialogResult.OK)
                {
                    int shadow    = hsform.getShadow;
                    int highlight = hsform.getHighlight;
                    curBitmap = zPhoto.HighlightShadowPreciseAdjustProcess(curBitmap, highlight, shadow);
                    //Bitmap tmp = zPhoto.ShadowAdjust(curBitmap, shadow, 100);
                    //curBitmap = zPhoto.HighlightAdjust(tmp, highlight, 100);
                }
                break;

            case ImageProcessId.ID_EXPOSURE:
                ExposureForm eform = new ExposureForm(curFileName);
                if (eform.ShowDialog() == DialogResult.OK)
                {
                    int intensity = eform.getIntensity;
                    curBitmap = zPhoto.ExposureAdjust(curBitmap, intensity);
                }
                break;

            case ImageProcessId.ID_COLORTEMPEATURE:
                TempreatureForm teform = new TempreatureForm(curFileName);
                if (teform.ShowDialog() == DialogResult.OK)
                {
                    int intensity = teform.getTempeature;
                    curBitmap = zPhoto.ColorTemperatureProcess(curBitmap, intensity);
                }
                break;

            case ImageProcessId.ID_FINDEDGES:
                curBitmap = zPhoto.FindEdgesProcess(curBitmap);
                break;

            case ImageProcessId.ID_RELIEF:
                ReliefForm rform = new ReliefForm(curFileName);
                if (rform.ShowDialog() == DialogResult.OK)
                {
                    int angle  = rform.getAngle;
                    int amount = rform.getAmount;
                    curBitmap = zPhoto.Relief(curBitmap, angle, amount);
                }
                break;

            case ImageProcessId.ID_DIFUSSION:
                DifussionForm dform = new DifussionForm(curFileName);
                if (dform.ShowDialog() == DialogResult.OK)
                {
                    int intensity = dform.getIntensity;
                    curBitmap = zPhoto.DiffusionProcess(curBitmap, intensity);
                }
                break;

            case ImageProcessId.ID_OVEREXPOSURE:
                curBitmap = zPhoto.OverExposure(curBitmap);
                break;

            case ImageProcessId.ID_SURFACEBLUR:
                SurfaceBlurForm srform = new SurfaceBlurForm(curFileName);
                if (srform.ShowDialog() == DialogResult.OK)
                {
                    int radius    = srform.getRadius;
                    int threshold = srform.getThreshld;
                    curBitmap = zPhoto.SurfaceBlur(curBitmap, threshold, radius);
                }
                break;

            case ImageProcessId.ID_MOTIONBLUR:
                MotionBlurForm moform = new MotionBlurForm(curFileName);
                if (moform.ShowDialog() == DialogResult.OK)
                {
                    int angle    = moform.getAngle;
                    int distance = moform.getDistance;
                    curBitmap = zPhoto.MotionBlur(curBitmap, angle, distance);
                }
                break;

            case ImageProcessId.ID_MEANBLUR:
                MeanBlurForm meform = new MeanBlurForm(curFileName);
                if (meform.ShowDialog() == DialogResult.OK)
                {
                    int radius = meform.getRadius;
                    curBitmap = zPhoto.MeanFilterProcess(curBitmap, radius);
                }
                break;

            case ImageProcessId.ID_GAUSSBLUR:
                GaussBlurForm gauform = new GaussBlurForm(curFileName);
                if (gauform.ShowDialog() == DialogResult.OK)
                {
                    double radius = gauform.getRadius;
                    curBitmap = zPhoto.GaussFilterProcess(curBitmap, (float)radius);
                }
                break;

            case ImageProcessId.ID_RADIAL:
                RadialBlurForm raform = new RadialBlurForm(curFileName);
                if (raform.ShowDialog() == DialogResult.OK)
                {
                    int amount = raform.getAmount;
                    curBitmap = zPhoto.RadialBlurProcess(curBitmap, amount);
                }
                break;

            case ImageProcessId.ID_ZOOMBLUR:
                ZoomBlurForm zoomform = new ZoomBlurForm(curFileName);
                if (zoomform.ShowDialog() == DialogResult.OK)
                {
                    int amount = zoomform.getAmount;
                    int radius = zoomform.getRadius;
                    curBitmap = zPhoto.ZoomBlurProcess(curBitmap, radius, amount);
                }
                break;

            case ImageProcessId.ID_MEAN:
                curBitmap = zPhoto.MeanProcess(curBitmap);
                break;

            case ImageProcessId.ID_MOSCIA:
                MosciaForm mosciaform = new MosciaForm(curFileName);
                if (mosciaform.ShowDialog() == DialogResult.OK)
                {
                    int blockSize = mosciaform.getBlocksize;
                    curBitmap = zPhoto.MosaicProcess(curBitmap, blockSize);
                }
                break;

            case ImageProcessId.ID_FRAGMENT:
                curBitmap = zPhoto.Fragment(curBitmap);
                break;

            case ImageProcessId.ID_HIGHPASS:
                HighpassForm hpform = new HighpassForm(curFileName);
                if (hpform.ShowDialog() == DialogResult.OK)
                {
                    double radius = hpform.getRadius;
                    curBitmap = zPhoto.HighPassProcess(curBitmap, (float)radius);
                }
                break;

            case ImageProcessId.ID_USM:
                USMForm usmform = new USMForm(curFileName);
                if (usmform.ShowDialog() == DialogResult.OK)
                {
                    double radius    = usmform.getRadius;
                    int    amount    = usmform.getAmount;
                    int    threshold = usmform.getThreshold;
                    curBitmap = zPhoto.USMProcess(curBitmap, (float)radius, amount, threshold);
                }
                break;

            case ImageProcessId.ID_CHANNELMIXER:
                ChannelMixForm cmform = new ChannelMixForm(curFileName);
                if (cmform.ShowDialog() == DialogResult.OK)
                {
                    curBitmap = new Bitmap(cmform.getResImage);
                }
                break;

            case ImageProcessId.ID_BLACKWHITE:
                BlackWhiteForm whform = new BlackWhiteForm(curFileName);
                if (whform.ShowDialog() == DialogResult.OK)
                {
                    curBitmap = zPhoto.BlackwhiteProcess(curBitmap, whform.getKRed, whform.getKGreen, whform.getKBlue, whform.getKYellow, whform.getKCyan, whform.getKMagenta);
                }
                break;

            case ImageProcessId.ID_GAMMA:
                GammaForm gammaForm = new GammaForm(curFileName);
                if (gammaForm.ShowDialog() == DialogResult.OK)
                {
                    curBitmap = zPhoto.GammaCorrectProcess(curBitmap, gammaForm.getGamma);
                }
                break;

            case ImageProcessId.ID_MEDIANFILTER:
                MedianForm medianForm = new MedianForm(curFileName);
                if (medianForm.ShowDialog() == DialogResult.OK)
                {
                    curBitmap = zPhoto.MedianFilterProcess(curBitmap, medianForm.getRadius);
                }
                break;

            case ImageProcessId.ID_MAXFILTER:
                MaxForm maxForm = new MaxForm(curFileName);
                if (maxForm.ShowDialog() == DialogResult.OK)
                {
                    curBitmap = zPhoto.MaxFilterProcess(curBitmap, maxForm.getRadius);
                }
                break;

            case ImageProcessId.ID_MINFILTER:
                MinForm minForm = new MinForm(curFileName);
                if (minForm.ShowDialog() == DialogResult.OK)
                {
                    curBitmap = zPhoto.MinFilterProcess(curBitmap, minForm.getRadius);
                }
                break;

            case ImageProcessId.ID_NATURALSATURATION:
                NSaturationForm nsatForm = new NSaturationForm(curFileName);
                if (nsatForm.ShowDialog() == DialogResult.OK)
                {
                    curBitmap = zPhoto.NaturalSaturationProcess(curBitmap, nsatForm.getSaturation);
                }
                break;

            case ImageProcessId.ID_IMAGEWARP_WAVE:
                curBitmap = zPhoto.ImageWarpWaveProcess(curBitmap, 60);
                /////////////////////////////////////////////////////////

                break;

            case ImageProcessId.ID_SMARTBLUR:
                SmartBlurForm sbform = new SmartBlurForm(curFileName);
                if (sbform.ShowDialog() == DialogResult.OK)
                {
                    int radius    = sbform.getRadius;
                    int threshold = sbform.getThreshld;
                    curBitmap = zPhoto.SmartBlurProcess(curBitmap, radius, threshold);
                }
                break;

            case ImageProcessId.ID_DISPLACEMENTFILTER:
                DisplacementFrom displacementform = new DisplacementFrom();
                if (displacementform.ShowDialog() == DialogResult.OK)
                {
                    string mskPath = displacementform.getMaskPath;
                    int    hRatio  = displacementform.getHRatio;
                    int    vRatio  = displacementform.getVRatio;
                    try
                    {
                        curBitmap = zPhoto.DisplacementFilter(curBitmap, new Bitmap(mskPath), hRatio, vRatio);
                    }
                    catch (Exception exp)
                    {
                        MessageBox.Show("Please check input params!");
                    }
                }
                break;

            case ImageProcessId.ID_NOISEEFFECT:
                curBitmap = zPhoto.NoiseEffect(curBitmap, 100, 0.5f, 50.0f);
                break;

            default:
                break;
            }
        }