public SepiaEffect () { desat = new UnaryPixelOps.Desaturate (); level = new UnaryPixelOps.Level ( ColorBgra.Black, ColorBgra.White, new float[] { 1.2f, 1.0f, 0.8f }, ColorBgra.Black, ColorBgra.White); }
public override void Render (ImageSurface src, ImageSurface dest, Gdk.Rectangle[] rois) { if (Data.ControlPoints == null) return; if (op == null) op = MakeUop (); op.Apply (dest, src, rois); }
public override void Render (ImageSurface src, ImageSurface dest, Gdk.Rectangle[] rois) { int hue_delta = Data.Hue; int sat_delta = Data.Saturation; int lightness = Data.Lightness; if (op == null) { if (hue_delta == 0 && sat_delta == 100 && lightness == 0) op = new UnaryPixelOps.Identity (); else op = new UnaryPixelOps.HueSaturationLightness (hue_delta, sat_delta, lightness); } op.Apply (dest, src, rois); }
private UnaryPixelOp MakeUop() { UnaryPixelOp op; byte[][] transferCurves; int entries; switch (Data.Mode) { case ColorTransferMode.Rgb: UnaryPixelOps.ChannelCurve cc = new UnaryPixelOps.ChannelCurve(); transferCurves = new byte[][] { cc.CurveR, cc.CurveG, cc.CurveB }; entries = 256; op = cc; break; case ColorTransferMode.Luminosity: UnaryPixelOps.LuminosityCurve lc = new UnaryPixelOps.LuminosityCurve(); transferCurves = new byte[][] { lc.Curve }; entries = 256; op = lc; break; default: throw new InvalidEnumArgumentException(); } int channels = transferCurves.Length; for (int channel = 0; channel < channels; channel++) { SortedList<int, int> channelControlPoints = Data.ControlPoints[channel]; IList<int> xa = channelControlPoints.Keys; IList<int> ya = channelControlPoints.Values; SplineInterpolator interpolator = new SplineInterpolator(); int length = channelControlPoints.Count; for (int i = 0; i < length; i++) { interpolator.Add(xa[i], ya[i]); } for (int i = 0; i < entries; i++) { transferCurves[channel][i] = Utility.ClampToByte(interpolator.Interpolate(i)); } } return op; }
public override bool LaunchConfiguration () { SimpleEffectDialog dialog = new SimpleEffectDialog (Name, PintaCore.Resources.GetIcon (Icon), Data, new PintaLocalizer ()); // Hookup event handling for live preview. dialog.EffectDataChanged += (o, e) => { if (EffectData != null) { op = new UnaryPixelOps.RedEyeRemove (Data.Tolerance, Data.Saturation); EffectData.FirePropertyChanged (e.PropertyName); } }; int response = dialog.Run (); bool ret = (response == (int)Gtk.ResponseType.Ok); dialog.Destroy (); return ret; }
public HueSaturationLightness(int hueDelta, int satDelta, int lightness) { this.hueDelta = hueDelta; this.satFactor = (satDelta * 1024) / 100; if (lightness == 0) { blendOp = new UnaryPixelOps.Identity(); } else if (lightness > 0) { blendOp = new UnaryPixelOps.BlendConstant(ColorBgra.FromBgra(255, 255, 255, (byte)((lightness * 255) / 100))); } else // if (lightness < 0) { blendOp = new UnaryPixelOps.BlendConstant(ColorBgra.FromBgra(0, 0, 0, (byte)((-lightness * 255) / 100))); } }
public override void RenderEffect(ImageSurface src, ImageSurface dest, Gdk.Rectangle[] rois) { if (hue_delta == 0 && sat_delta == 100 && lightness == 0) op = new UnaryPixelOps.Identity (); else op = new UnaryPixelOps.HueSaturationLightness (hue_delta, sat_delta, lightness); op.Apply (dest, src, rois); }
public override void RenderEffect(ImageSurface src, ImageSurface dest, Gdk.Rectangle[] rois) { op = new UnaryPixelOps.PosterizePixel (red, green, blue); op.Apply (dest, src, rois); }