private void BlackWhite(int mode) { switch (mode) { case 0: //default kRed = 40; kYellow = 60; kGreen = 40; kCyan = 60; kBlue = 20; kMagenta = 80; break; case 1: //蓝色滤镜 kRed = 0; kYellow = 0; kGreen = 0; kCyan = 110; kBlue = 110; kMagenta = 110; break; case 2: //较暗 kRed = 30; kYellow = 50; kGreen = 30; kCyan = 50; kBlue = 10; kMagenta = 70; break; case 3: //绿色滤镜 kRed = 50; kYellow = 120; kGreen = 90; kCyan = 50; kBlue = 0; kMagenta = 0; break; case 4: //高对比度蓝色滤镜 kRed = -50; kYellow = -50; kGreen = -50; kCyan = 150; kBlue = 150; kMagenta = 150; break; case 5: //高对比度红色滤镜 kRed = 120; kYellow = 120; kGreen = -10; kCyan = -50; kBlue = -50; kMagenta = 120; break; case 6: //红外线 kRed = -40; kYellow = 235; kGreen = 144; kCyan = -68; kBlue = -3; kMagenta = -107; break; case 7: //较亮 kRed = 50; kYellow = 70; kGreen = 50; kCyan = 70; kBlue = 30; kMagenta = 90; break; case 8: //最黑 kRed = 0; kYellow = 0; kGreen = 0; kCyan = 0; kBlue = 0; kMagenta = 0; break; case 9: //最白 kRed = 100; kYellow = 100; kGreen = 100; kCyan = 100; kBlue = 100; kMagenta = 100; break; case 10: //中灰密度 kRed = 128; kYellow = 128; kGreen = 100; kCyan = 100; kBlue = 128; kMagenta = 100; break; case 11: //红色滤镜 kRed = 120; kYellow = 110; kGreen = -10; kCyan = -50; kBlue = 0; kMagenta = 120; break; case 12: //黄色滤镜 kRed = 120; kYellow = 110; kGreen = 40; kCyan = -30; kBlue = 0; kMagenta = 70; break; default: kRed = 40; kYellow = 60; kGreen = 40; kCyan = 60; kBlue = 20; kMagenta = 80; break; } hScrollBar1.Value = kRed; hScrollBar2.Value = kYellow; hScrollBar3.Value = kGreen; hScrollBar4.Value = kCyan; hScrollBar5.Value = kBlue; hScrollBar6.Value = kMagenta; textBox1.Text = kRed.ToString(); textBox2.Text = kYellow.ToString(); textBox3.Text = kGreen.ToString(); textBox4.Text = kCyan.ToString(); textBox5.Text = kBlue.ToString(); textBox6.Text = kMagenta.ToString(); if (pictureBox1.Image != null) { pictureBox1.Image = (Image)zPhoto.BlackwhiteProcess(curBitmap, kRed, kGreen, kBlue, kYellow, kCyan, kMagenta); } }
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; } }