Exemplo n.º 1
0
		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);
		}
Exemplo n.º 2
0
		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);
		}
Exemplo n.º 3
0
		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);
		}
Exemplo n.º 4
0
		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;
        }
Exemplo n.º 5
0
		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;
		}
Exemplo n.º 6
0
            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)));
                }
            }
Exemplo n.º 7
0
        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);
        }
Exemplo n.º 8
0
        public override void RenderEffect(ImageSurface src, ImageSurface dest, Gdk.Rectangle[] rois)
        {
            op = new UnaryPixelOps.PosterizePixel (red, green, blue);

            op.Apply (dest, src, rois);
        }