Exemple #1
0
 override public bool Execute()
 {
     // TODO: check if pattern "Clipboard" is actually available
     ActiveDrawable.EditCopy();
     Context.Pattern = new Pattern("Clipboard");
     return(true);
 }
Exemple #2
0
        override public bool Execute()
        {
            Context.Push();

            if (_color != null)
            {
                RGB foreground = _color.GetColor();

                if (foreground != null)
                {
                    Console.WriteLine("Ok2!");
                    Context.Foreground = foreground;
                }
            }
            else
            {
                Console.WriteLine("No color!");
            }

            Context.Opacity = _opacity;
            ActiveDrawable.EditStroke();
            Context.Pop();

            return(true);
        }
Exemple #3
0
        override public bool Execute()
        {
            bool nonEmpty;

            var rectangle = ActiveImage.Selection.Bounds(out nonEmpty);

            if (nonEmpty)
            {
                ActiveDrawable.EditCopy();
                ActiveDrawable.EditPaste(false);

                ActiveImage.FloatingSelection.Offsets =
                    new Offset(rectangle.X1, rectangle.Y1);
                var layer = ActiveImage.FloatingSelection.ToLayer();

                // Fix me: why can't I use layer here?
                var dummy = new Layer(ActiveImage.ActiveDrawable)
                {
                    Name = "Layer 1"
                };
                dummy.ResizeToImageSize();
            }
            else
            {
                var image = ActiveImage;
                var layer = new Layer(SelectedLayer)
                {
                    Name = "Layer 1"
                };
                image.InsertLayer(layer, 0);
                image.ActiveLayer = layer;
                SelectedLayer     = layer;
            }
            return(true);
        }
Exemple #4
0
 override public bool Execute()
 {
     ActiveDrawable.HueSaturation(HueRange.All, (double)_hue,
                                  (double)_lightness,
                                  (double)_saturation);
     return(true);
 }
Exemple #5
0
        override public bool Execute()
        {
            double angle = _angle * 2 * Math.PI / 360;

            ActiveDrawable.TransformRotate(angle, true, 0, 0, true, false);
            return(true);
        }
Exemple #6
0
        override public bool Execute()
        {
            bool wrapAround = (_fillMode.Value == "Wrp");

            ActiveDrawable.Offset(wrapAround, OffsetType.Background,
                                  _horizontal, _vertical);
            return(true);
        }
Exemple #7
0
 override public bool Execute()
 {
     if (!HasDescriptor)
     {
         ActiveDrawable.EditClear();
     }
     return(true);
 }
Exemple #8
0
        override public bool Execute()
        {
            if (_adjustment != null)
            {
                ObjcParameter objc = _adjustment[0] as ObjcParameter;

                ReferenceParameter obj = objc.Parameters["Chnl"] as
                                         ReferenceParameter;
                string origChannel = (obj.Set[0] as EnmrType).Value;

                ListParameter curve = objc.Parameters["Crv"] as ListParameter;

                CoordinateList <byte> controlPoints = new CoordinateList <byte>();

                foreach (Parameter parameter in curve)
                {
                    ObjcParameter point = parameter as ObjcParameter;
                    double        x     =
                        (point.Parameters["Hrzn"] as DoubleParameter).Value;
                    double y =
                        (point.Parameters["Vrtc"] as DoubleParameter).Value;

                    controlPoints.Add(new Coordinate <byte>((byte)x, (byte)y));
                }

                HistogramChannel channel;

                switch (origChannel)
                {
                case "Cmps":
                    channel = HistogramChannel.Value;
                    break;

                case "Rd":
                    channel = HistogramChannel.Red;
                    break;

                case "Grn":
                    channel = HistogramChannel.Green;
                    break;

                case "Bl":
                    channel = HistogramChannel.Blue;
                    break;

                default:
                    Console.WriteLine("CurvesEvent: " + origChannel);
                    return(false);
                }

                ActiveDrawable.CurvesSpline(channel, controlPoints);
            }
            else
            {
                Console.WriteLine("CurvesEvent: adjustment == null?");
            }
            return(true);
        }
Exemple #9
0
        override public bool Execute()
        {
            var random = new Random();

            RunProcedure("plug_in_plasma", random.Next(), 1.0);
            ActiveDrawable.Desaturate();

            return(true);
        }
Exemple #10
0
 override public bool Execute()
 {
     // TODO: check parameters!
     if (_level > 254)
     {
         _level = 254;
     }
     ActiveDrawable.Threshold(_level, 255);
     return(true);
 }
 override public bool Execute()
 {
     if (ActiveDrawable == null)
     {
         Console.WriteLine("Please open image first");
         return(false);
     }
     ActiveDrawable.Desaturate();
     return(true);
 }
Exemple #12
0
        override public bool Execute()
        {
#if false
            RunProcedure("plug_in_sobel", 1, 1, 1);
            ActiveDrawable.Invert();
#else
            RunProcedure("plug_in_dog", 3, 1, true, true);
#endif
            return(true);
        }
Exemple #13
0
        override public bool Execute()
        {
            double x1 = _from.GetValueAsDouble("Hrzn");
            double y1 = _from.GetValueAsDouble("Vrtc");

            double x2 = _to.GetValueAsDouble("Hrzn");
            double y2 = _to.GetValueAsDouble("Vrtc");

            Console.WriteLine("from ({0}, {1}) to ({2}, {3})", x1, y1, x2, y2);

            // Fix me!
            GradientType gradientType;

            switch (_type.Value)
            {
            case "Lnr":
                gradientType = GradientType.Linear;
                break;

            default:
                Console.WriteLine("Gradient-2: " + _type.Value);
                gradientType = GradientType.Linear;
                break;
            }

            Gradient gradient;

            if (_gradient != null)
            {
                string name = _gradient.GetValueAsString("Nm");
                Console.WriteLine("Name: " + name);
                ListParameter colors = _gradient.Parameters["Clrs"] as ListParameter;

                gradient = CreateGradient(name, colors);
            }
            else if (_with != null)
            {
                gradient = CreateGradient("Photoshop.Temp", _with);
            }
            else
            {
                Console.WriteLine("Gradient-3");
                return(false);
            }

            Context.Push();
            Context.Gradient = gradient;
            ActiveDrawable.EditBlend(BlendMode.Custom, LayerModeEffects.Normal,
                                     gradientType, 100.0, 0.0, RepeatMode.None,
                                     false, false, 0, 0, _dither,
                                     x1, y1, x2, y2);
            Context.Pop();

            return(true);
        }
Exemple #14
0
        override public bool Execute()
        {
            var selection = ActiveDrawable.EditPaste(false);

            selection.ToLayer();

            selection.Name = "Layer 1";

            SelectedLayer = selection;
            return(true);
        }
Exemple #15
0
        override public bool Execute()
        {
            CoordinateList <byte> controlPoints = new CoordinateList <byte>()
            {
                new Coordinate <byte>(0, 0),
                new Coordinate <byte>(127, 127),
                new Coordinate <byte>(255, 0)
            };

            ActiveDrawable.CurvesSpline(HistogramChannel.Value, controlPoints);
            return(true);
        }
        void SetBalance(ListParameter parameter, TransferMode transferMode)
        {
            int cyanRed      = (parameter[0] as LongParameter).Value;
            int magentaGreen = (parameter[1] as LongParameter).Value;
            int yellowBlue   = (parameter[2] as LongParameter).Value;

            if (cyanRed != 0 || magentaGreen != 0 || yellowBlue != 0)
            {
                ActiveDrawable.ColorBalance(transferMode, _preserveLuminosity,
                                            cyanRed, magentaGreen, yellowBlue);
            }
        }
Exemple #17
0
        override public bool Execute()
        {
            if (Parameters["AuCo"] != null)
            {
                RunProcedure("plug_in_autostretch_hsv");
            }
            if (Parameters["autoBlackWhite"] != null)
            {
                Console.WriteLine("Levels:autoBlackWhite not implemented yet");
            }
            if (Parameters["autoNeutrals"] != null)
            {
                Console.WriteLine("Levels:autoNeutrals not implemented yet");
            }
            if (Parameters["Auto"] != null)
            {
                ActiveDrawable.LevelsStretch();
            }

            if (_adjustment != null)
            {
                ObjcParameter objc  = _adjustment[0] as ObjcParameter;
                double        gamma = (objc.Parameters["Gmm"] as DoubleParameter).Value;

                ReferenceParameter obj = objc.Parameters["Chnl"] as
                                         ReferenceParameter;
                string channel = (obj.Set[0] as EnmrType).Value;

                if (channel == "Cmps")
                {
                    ActiveDrawable.Levels(HistogramChannel.Value, 0, 255, gamma,
                                          0, 255);
                }
                else
                {
                    Console.WriteLine("LevelsEvent: " + channel);
                }
            }

            return(true);
        }
Exemple #18
0
        override public bool Execute()
        {
            // Look for script-fu-selection-to-pattern as example. The basic idea
            // is to create a new image and save it as a .pat file

            var  selection = ActiveImage.Selection;
            bool nonEmpty;
            var  bounds = selection.Bounds(out nonEmpty);
            int  width  = bounds.Width;
            int  height = bounds.Height;

            var image = new Image(width, height, ActiveImage.BaseType);
            var layer = new Layer(image, "test", width, height,
                                  ImageType.Rgb, 100,
                                  LayerModeEffects.Normal);

            image.InsertLayer(layer, 0);
            Console.WriteLine("{0} {1}", image.Width, image.Height);

            ActiveDrawable.EditCopy();
            layer.EditPaste(true);

            string filename = Gimp.Directory + System.IO.Path.DirectorySeparatorChar
                              + "patterns" + System.IO.Path.DirectorySeparatorChar +
                              _name + ".pat";

            image.Save(RunMode.Noninteractive, filename, filename);

            // Fix me: next lines should work so we can actually set the name
            // of the pattern!
            // Procedure procedure = new Procedure("file_pat_save");
            // procedure.Run(image, layer, filename, filename, _name);

            image.Delete();
            PatternList.Refresh();

            return(false);
        }
Exemple #19
0
        override public bool Execute()
        {
            bool nonEmpty;

            Rectangle rectangle = ActiveImage.Selection.Bounds(out nonEmpty);

            if (nonEmpty)
            {
                ActiveDrawable.EditCut();
                ActiveDrawable.EditPaste(false);

                ActiveImage.FloatingSelection.Offsets =
                    new Offset(rectangle.X1, rectangle.Y1);
                Layer layer = ActiveImage.FloatingSelection.ToLayer();
                // Fix me: why can't I use layer here?
                new Layer(ActiveImage.ActiveDrawable).ResizeToImageSize();
            }
            else
            {
                // TODO: what does PS handle this?
            }
            return(true);
        }
Exemple #20
0
 override public bool Execute()
 {
     ActiveDrawable.EditCopy();
     return(true);
 }
Exemple #21
0
 override public bool Execute()
 {
     ActiveDrawable.Equalize(false);
     return(true);
 }
Exemple #22
0
 public override bool Execute()
 {
     ActiveDrawable.BrightnessContrast(_brightness, _contrast);
     return(true);
 }
Exemple #23
0
 override public bool Execute()
 {
     ActiveDrawable.Offset(false, OffsetType.Transparent, (int)_horizontal,
                           (int)_vertical);
     return(true);
 }
 override public bool Execute()
 {
     ActiveDrawable.Posterize(_levels);
     return(true);
 }