protected CurvesEffectConfigToken(CurvesEffectConfigToken copyMe) : base(copyMe) { this.uop = copyMe.Uop; this.colorTransferMode = copyMe.ColorTransferMode; this.controlPoints = (SortedList<int, int>[])copyMe.controlPoints.Clone(); }
public HueSaturationLightnessOp (int hueDelta, int satDelta, int lightness) { hue_delta = hueDelta; sat_factor = (satDelta * 1024) / 100; if (lightness == 0) blend_op = new IdentityOp (); else if (lightness > 0) blend_op = new BlendConstantOp (ColorBgra.FromBgra (255, 255, 255, (byte)((lightness * 255) / 100))); else blend_op = new BlendConstantOp (ColorBgra.FromBgra (0, 0, 0, (byte)((-lightness * 255) / 100))); }
public SepiaEffect() : base(PdnResources.GetString("SepiaEffect.Name"), PdnResources.GetImage("Icons.SepiaEffect.png")) { this.desaturate = new UnaryPixelOps.Desaturate(); this.levels = new UnaryPixelOps.Level( ColorBgra.Black, ColorBgra.White, new float[] { 1.2f, 1.0f, 0.8f }, ColorBgra.Black, ColorBgra.White); }
/// <summary> /// Creates a new effect that will adjust the hue, saturation, and lightness of an image. /// </summary> /// <param name="hue">Amount of hue to adjust. Valid range is -180 - 180.</param> /// <param name="saturation">Amount of saturation to adjust. Valid range is 0 - 200.</param> /// <param name="lightness">Amount of of lightness to adjust. Valid range is -100 - 100.</param> public HueSaturationEffect (int hue = 0, int saturation = 100, int lightness = 0) { if (hue < -180 || hue > 180) throw new ArgumentOutOfRangeException ("hue"); if (saturation < 0 || saturation > 200) throw new ArgumentOutOfRangeException ("saturation"); if (lightness < -100 || lightness > 100) throw new ArgumentOutOfRangeException ("lightness"); if (hue == 0 && saturation == 100 && lightness == 0) op = new IdentityOp (); else op = new HueSaturationLightnessOp (hue, saturation, lightness); }
private UnaryPixelOp MakeUop (SortedList<int, int>[] controlPoints, ColorTransferMode mode) { UnaryPixelOp op; byte[][] transferCurves; int entries; switch (mode) { case ColorTransferMode.Rgb: var cc = new ChannelCurveOp (); transferCurves = new byte[][] { cc.CurveR, cc.CurveG, cc.CurveB }; entries = 256; op = cc; break; case ColorTransferMode.Luminosity: var lc = new LuminosityCurveOp (); 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++) { var channelControlPoints = controlPoints[channel]; var xa = channelControlPoints.Keys; var 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; }
protected override void OnSetRenderInfo(PropertyBasedEffectConfigToken newToken, RenderArgs dstArgs, RenderArgs srcArgs) { int red = newToken.GetProperty<Int32Property>(PropertyNames.RedLevels).Value; int green = newToken.GetProperty<Int32Property>(PropertyNames.GreenLevels).Value; int blue = newToken.GetProperty<Int32Property>(PropertyNames.BlueLevels).Value; this.op = new PosterizePixelOp(red, green, blue); base.OnSetRenderInfo(newToken, dstArgs, srcArgs); }
public CurvesEffect(SortedList <int, int>[] controlPoints, ColorTransferMode mode) { op = MakeUop(controlPoints, mode); }
public void SetParameters(int red, int green, int blue) { this.op = new PosterizePixelOp(red, green, blue); }
public CurvesEffect (SortedList<int, int>[] controlPoints, ColorTransferMode mode) { op = MakeUop (controlPoints, mode); }