[gimp] plug-ins, pdb: remove the value-propagate plug-in and add PDB compat procedures



commit b856a8ba76d98be2fb38d9a8bd83212327f79fbd
Author: Michael Natterer <mitch gimp org>
Date:   Sun Feb 8 23:09:06 2015 +0100

    plug-ins, pdb: remove the value-propagate plug-in and add PDB compat procedures

 app/pdb/internal-procs.c            |    2 +-
 app/pdb/plug-in-compat-cmds.c       |  414 +++++++++++
 plug-ins/common/.gitignore          |    2 -
 plug-ins/common/Makefile.am         |   18 -
 plug-ins/common/gimprc.common       |    1 -
 plug-ins/common/plugin-defs.pl      |    1 -
 plug-ins/common/value-propagate.c   | 1294 -----------------------------------
 po-plug-ins/POTFILES.in             |    1 -
 tools/pdbgen/pdb/plug_in_compat.pdb |  243 +++++++
 9 files changed, 658 insertions(+), 1318 deletions(-)
---
diff --git a/app/pdb/internal-procs.c b/app/pdb/internal-procs.c
index 830e322..64d0540 100644
--- a/app/pdb/internal-procs.c
+++ b/app/pdb/internal-procs.c
@@ -28,7 +28,7 @@
 #include "internal-procs.h"
 
 
-/* 750 procedures registered total */
+/* 753 procedures registered total */
 
 void
 internal_procs_init (GimpPDB *pdb)
diff --git a/app/pdb/plug-in-compat-cmds.c b/app/pdb/plug-in-compat-cmds.c
index 4d43dc0..f6347ee 100644
--- a/app/pdb/plug-in-compat-cmds.c
+++ b/app/pdb/plug-in-compat-cmds.c
@@ -3014,6 +3014,204 @@ plug_in_vinvert_invoker (GimpProcedure         *procedure,
 }
 
 static GimpValueArray *
+plug_in_vpropagate_invoker (GimpProcedure         *procedure,
+                            Gimp                  *gimp,
+                            GimpContext           *context,
+                            GimpProgress          *progress,
+                            const GimpValueArray  *args,
+                            GError               **error)
+{
+  gboolean success = TRUE;
+  GimpDrawable *drawable;
+  gint32 propagate_mode;
+  gint32 propagating_channel;
+  gdouble propagating_rate;
+  gint32 direction_mask;
+  gint32 lower_limit;
+  gint32 upper_limit;
+
+  drawable = gimp_value_get_drawable (gimp_value_array_index (args, 2), gimp);
+  propagate_mode = g_value_get_int (gimp_value_array_index (args, 3));
+  propagating_channel = g_value_get_int (gimp_value_array_index (args, 4));
+  propagating_rate = g_value_get_double (gimp_value_array_index (args, 5));
+  direction_mask = g_value_get_int (gimp_value_array_index (args, 6));
+  lower_limit = g_value_get_int (gimp_value_array_index (args, 7));
+  upper_limit = g_value_get_int (gimp_value_array_index (args, 8));
+
+  if (success)
+    {
+      if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL,
+                                     GIMP_PDB_ITEM_CONTENT, error) &&
+          gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error))
+        {
+          GeglNode  *node;
+          GimpRGB    color;
+          GeglColor *gegl_color = NULL;
+          gint       gegl_mode  = 0;
+          gboolean   to_left    = (direction_mask & (0x1 << 0)) != 0;
+          gboolean   to_top     = (direction_mask & (0x1 << 1)) != 0;
+          gboolean   to_right   = (direction_mask & (0x1 << 2)) != 0;
+          gboolean   to_bottom  = (direction_mask & (0x1 << 3)) != 0;
+          gboolean   value      = (propagating_channel & (0x1 << 0)) != 0;
+          gboolean   alpha      = (propagating_channel & (0x1 << 1)) != 0;
+
+          switch (propagate_mode)
+            {
+            case 0:
+            case 1:
+            case 2:
+              gegl_mode = propagate_mode;
+              break;
+
+            case 3:
+              gegl_mode = propagate_mode;
+              /* fall thru */
+
+            case 4:
+            case 5:
+              gegl_mode = 4;
+
+              if (propagate_mode != 3)
+                gimp_context_get_foreground (context, &color);
+              else
+                gimp_context_get_background (context, &color);
+
+              gegl_color = gimp_gegl_color_new (&color);
+              break;
+
+            case 6:
+            case 7:
+              gegl_mode = propagate_mode - 1;
+              break;
+            }
+
+          node =
+            gegl_node_new_child (NULL,
+                                 "operation",        "gegl:value-propagate",
+                                 "mode",             gegl_mode,
+                                 "lower-threshold",  (gdouble) lower_limit / 255.0,
+                                 "upper-threshold",  (gdouble) upper_limit / 255.0,
+                                 "rate",             propagating_rate,
+                                 "color",            gegl_color,
+                                 "top",              to_top,
+                                 "left",             to_left,
+                                 "right",            to_right,
+                                 "bottom",           to_bottom,
+                                 "value",            value,
+                                 "alpha",            alpha,
+                                 NULL);
+
+          if (gegl_color)
+            g_object_unref (gegl_color);
+
+          gimp_drawable_apply_operation (drawable, progress,
+                                         C_("undo-type", "Value Propagate"),
+                                         node);
+          g_object_unref (node);
+        }
+      else
+        success = FALSE;
+    }
+
+  return gimp_procedure_get_return_values (procedure, success,
+                                           error ? *error : NULL);
+}
+
+static GimpValueArray *
+plug_in_dilate_invoker (GimpProcedure         *procedure,
+                        Gimp                  *gimp,
+                        GimpContext           *context,
+                        GimpProgress          *progress,
+                        const GimpValueArray  *args,
+                        GError               **error)
+{
+  gboolean success = TRUE;
+  GimpDrawable *drawable;
+
+  drawable = gimp_value_get_drawable (gimp_value_array_index (args, 2), gimp);
+
+  if (success)
+    {
+      if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL,
+                                     GIMP_PDB_ITEM_CONTENT, error) &&
+          gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error))
+        {
+          GeglNode *node =
+            gegl_node_new_child (NULL,
+                                 "operation",       "gegl:value-propagate",
+                                 "mode",            0, /* GEGL_VALUE_PROPAGATE_MODE_WHITE */
+                                 "lower-threshold", 0.0,
+                                 "upper-threshold", 1.0,
+                                 "rate",            1.0,
+                                 "top",             TRUE,
+                                 "left",            TRUE,
+                                 "right",           TRUE,
+                                 "bottom",          TRUE,
+                                 "value",           TRUE,
+                                 "alpha",           FALSE,
+                                 NULL);
+
+          gimp_drawable_apply_operation (drawable, progress,
+                                         C_("undo-type", "Dilate"),
+                                         node);
+          g_object_unref (node);
+        }
+      else
+        success = FALSE;
+    }
+
+  return gimp_procedure_get_return_values (procedure, success,
+                                           error ? *error : NULL);
+}
+
+static GimpValueArray *
+plug_in_erode_invoker (GimpProcedure         *procedure,
+                       Gimp                  *gimp,
+                       GimpContext           *context,
+                       GimpProgress          *progress,
+                       const GimpValueArray  *args,
+                       GError               **error)
+{
+  gboolean success = TRUE;
+  GimpDrawable *drawable;
+
+  drawable = gimp_value_get_drawable (gimp_value_array_index (args, 2), gimp);
+
+  if (success)
+    {
+      if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL,
+                                     GIMP_PDB_ITEM_CONTENT, error) &&
+          gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error))
+        {
+          GeglNode *node =
+            gegl_node_new_child (NULL,
+                                 "operation",       "gegl:value-propagate",
+                                 "mode",            1, /* GEGL_VALUE_PROPAGATE_MODE_BLACK */
+                                 "lower-threshold", 0.0,
+                                 "upper-threshold", 1.0,
+                                 "rate",            1.0,
+                                 "top",             TRUE,
+                                 "left",            TRUE,
+                                 "right",           TRUE,
+                                 "bottom",          TRUE,
+                                 "value",           TRUE,
+                                 "alpha",           FALSE,
+                                 NULL);
+
+          gimp_drawable_apply_operation (drawable, progress,
+                                         C_("undo-type", "Erode"),
+                                         node);
+          g_object_unref (node);
+        }
+      else
+        success = FALSE;
+    }
+
+  return gimp_procedure_get_return_values (procedure, success,
+                                           error ? *error : NULL);
+}
+
+static GimpValueArray *
 plug_in_waves_invoker (GimpProcedure         *procedure,
                        Gimp                  *gimp,
                        GimpContext           *context,
@@ -6114,6 +6312,222 @@ register_plug_in_compat_procs (GimpPDB *pdb)
   g_object_unref (procedure);
 
   /*
+   * gimp-plug-in-vpropagate
+   */
+  procedure = gimp_procedure_new (plug_in_vpropagate_invoker);
+  gimp_object_set_static_name (GIMP_OBJECT (procedure),
+                               "plug-in-vpropagate");
+  gimp_procedure_set_static_strings (procedure,
+                                     "plug-in-vpropagate",
+                                     "Propagate certain colors to neighboring pixels",
+                                     "Propagate values of the layer.",
+                                     "Compatibility procedure. Please see 'gegl:value-propagate' for 
credits.",
+                                     "Compatibility procedure. Please see 'gegl:value-propagate' for 
credits.",
+                                     "2015",
+                                     NULL);
+  gimp_procedure_add_argument (procedure,
+                               g_param_spec_enum ("run-mode",
+                                                  "run mode",
+                                                  "The run mode",
+                                                  GIMP_TYPE_RUN_MODE,
+                                                  GIMP_RUN_INTERACTIVE,
+                                                  GIMP_PARAM_READWRITE));
+  gimp_procedure_add_argument (procedure,
+                               gimp_param_spec_image_id ("image",
+                                                         "image",
+                                                         "Input image (unused)",
+                                                         pdb->gimp, FALSE,
+                                                         GIMP_PARAM_READWRITE));
+  gimp_procedure_add_argument (procedure,
+                               gimp_param_spec_drawable_id ("drawable",
+                                                            "drawable",
+                                                            "Input drawable",
+                                                            pdb->gimp, FALSE,
+                                                            GIMP_PARAM_READWRITE));
+  gimp_procedure_add_argument (procedure,
+                               gimp_param_spec_int32 ("propagate-mode",
+                                                      "propagate mode",
+                                                      "Propagate mode { 0:white, 1:black, 2:middle value 
3:foreground to peak, 4:foreground, 5:background, 6:opaque, 7:transparent }",
+                                                      0, 7, 0,
+                                                      GIMP_PARAM_READWRITE));
+  gimp_procedure_add_argument (procedure,
+                               gimp_param_spec_int32 ("propagating-channel",
+                                                      "propagating channel",
+                                                      "Channels which values are propagated",
+                                                      G_MININT32, G_MAXINT32, 0,
+                                                      GIMP_PARAM_READWRITE));
+  gimp_procedure_add_argument (procedure,
+                               g_param_spec_double ("propagating-rate",
+                                                    "propagating rate",
+                                                    "Propagating rate",
+                                                    0.0, 1.0, 0.0,
+                                                    GIMP_PARAM_READWRITE));
+  gimp_procedure_add_argument (procedure,
+                               gimp_param_spec_int32 ("direction-mask",
+                                                      "direction mask",
+                                                      "Direction mask",
+                                                      0, 15, 0,
+                                                      GIMP_PARAM_READWRITE));
+  gimp_procedure_add_argument (procedure,
+                               gimp_param_spec_int32 ("lower-limit",
+                                                      "lower limit",
+                                                      "Lower limit",
+                                                      0, 255, 0,
+                                                      GIMP_PARAM_READWRITE));
+  gimp_procedure_add_argument (procedure,
+                               gimp_param_spec_int32 ("upper-limit",
+                                                      "upper limit",
+                                                      "Upper limit",
+                                                      0, 255, 0,
+                                                      GIMP_PARAM_READWRITE));
+  gimp_pdb_register_procedure (pdb, procedure);
+  g_object_unref (procedure);
+
+  /*
+   * gimp-plug-in-dilate
+   */
+  procedure = gimp_procedure_new (plug_in_dilate_invoker);
+  gimp_object_set_static_name (GIMP_OBJECT (procedure),
+                               "plug-in-dilate");
+  gimp_procedure_set_static_strings (procedure,
+                                     "plug-in-dilate",
+                                     "Grow lighter areas of the image",
+                                     "Dilate image.",
+                                     "Compatibility procedure. Please see 'gegl:value-propagate' for 
credits.",
+                                     "Compatibility procedure. Please see 'gegl:value-propagate' for 
credits.",
+                                     "2015",
+                                     NULL);
+  gimp_procedure_add_argument (procedure,
+                               g_param_spec_enum ("run-mode",
+                                                  "run mode",
+                                                  "The run mode",
+                                                  GIMP_TYPE_RUN_MODE,
+                                                  GIMP_RUN_INTERACTIVE,
+                                                  GIMP_PARAM_READWRITE));
+  gimp_procedure_add_argument (procedure,
+                               gimp_param_spec_image_id ("image",
+                                                         "image",
+                                                         "Input image (unused)",
+                                                         pdb->gimp, FALSE,
+                                                         GIMP_PARAM_READWRITE));
+  gimp_procedure_add_argument (procedure,
+                               gimp_param_spec_drawable_id ("drawable",
+                                                            "drawable",
+                                                            "Input drawable",
+                                                            pdb->gimp, FALSE,
+                                                            GIMP_PARAM_READWRITE));
+  gimp_procedure_add_argument (procedure,
+                               gimp_param_spec_int32 ("propagate-mode",
+                                                      "propagate mode",
+                                                      "Propagate mode { 0:white, 1:black, 2:middle value 
3:foreground to peak, 4:foreground, 5:background, 6:opaque, 7:transparent }",
+                                                      0, 7, 0,
+                                                      GIMP_PARAM_READWRITE));
+  gimp_procedure_add_argument (procedure,
+                               gimp_param_spec_int32 ("propagating-channel",
+                                                      "propagating channel",
+                                                      "Channels which values are propagated",
+                                                      G_MININT32, G_MAXINT32, 0,
+                                                      GIMP_PARAM_READWRITE));
+  gimp_procedure_add_argument (procedure,
+                               g_param_spec_double ("propagating-rate",
+                                                    "propagating rate",
+                                                    "Propagating rate",
+                                                    0.0, 1.0, 0.0,
+                                                    GIMP_PARAM_READWRITE));
+  gimp_procedure_add_argument (procedure,
+                               gimp_param_spec_int32 ("direction-mask",
+                                                      "direction mask",
+                                                      "Direction mask",
+                                                      0, 15, 0,
+                                                      GIMP_PARAM_READWRITE));
+  gimp_procedure_add_argument (procedure,
+                               gimp_param_spec_int32 ("lower-limit",
+                                                      "lower limit",
+                                                      "Lower limit",
+                                                      0, 255, 0,
+                                                      GIMP_PARAM_READWRITE));
+  gimp_procedure_add_argument (procedure,
+                               gimp_param_spec_int32 ("upper-limit",
+                                                      "upper limit",
+                                                      "Upper limit",
+                                                      0, 255, 0,
+                                                      GIMP_PARAM_READWRITE));
+  gimp_pdb_register_procedure (pdb, procedure);
+  g_object_unref (procedure);
+
+  /*
+   * gimp-plug-in-erode
+   */
+  procedure = gimp_procedure_new (plug_in_erode_invoker);
+  gimp_object_set_static_name (GIMP_OBJECT (procedure),
+                               "plug-in-erode");
+  gimp_procedure_set_static_strings (procedure,
+                                     "plug-in-erode",
+                                     "Shrink lighter areas of the image",
+                                     "Erode image.",
+                                     "Compatibility procedure. Please see 'gegl:value-propagate' for 
credits.",
+                                     "Compatibility procedure. Please see 'gegl:value-propagate' for 
credits.",
+                                     "2015",
+                                     NULL);
+  gimp_procedure_add_argument (procedure,
+                               g_param_spec_enum ("run-mode",
+                                                  "run mode",
+                                                  "The run mode",
+                                                  GIMP_TYPE_RUN_MODE,
+                                                  GIMP_RUN_INTERACTIVE,
+                                                  GIMP_PARAM_READWRITE));
+  gimp_procedure_add_argument (procedure,
+                               gimp_param_spec_image_id ("image",
+                                                         "image",
+                                                         "Input image (unused)",
+                                                         pdb->gimp, FALSE,
+                                                         GIMP_PARAM_READWRITE));
+  gimp_procedure_add_argument (procedure,
+                               gimp_param_spec_drawable_id ("drawable",
+                                                            "drawable",
+                                                            "Input drawable",
+                                                            pdb->gimp, FALSE,
+                                                            GIMP_PARAM_READWRITE));
+  gimp_procedure_add_argument (procedure,
+                               gimp_param_spec_int32 ("propagate-mode",
+                                                      "propagate mode",
+                                                      "Propagate mode { 0:white, 1:black, 2:middle value 
3:foreground to peak, 4:foreground, 5:background, 6:opaque, 7:transparent }",
+                                                      0, 7, 0,
+                                                      GIMP_PARAM_READWRITE));
+  gimp_procedure_add_argument (procedure,
+                               gimp_param_spec_int32 ("propagating-channel",
+                                                      "propagating channel",
+                                                      "Channels which values are propagated",
+                                                      G_MININT32, G_MAXINT32, 0,
+                                                      GIMP_PARAM_READWRITE));
+  gimp_procedure_add_argument (procedure,
+                               g_param_spec_double ("propagating-rate",
+                                                    "propagating rate",
+                                                    "Propagating rate",
+                                                    0.0, 1.0, 0.0,
+                                                    GIMP_PARAM_READWRITE));
+  gimp_procedure_add_argument (procedure,
+                               gimp_param_spec_int32 ("direction-mask",
+                                                      "direction mask",
+                                                      "Direction mask",
+                                                      0, 15, 0,
+                                                      GIMP_PARAM_READWRITE));
+  gimp_procedure_add_argument (procedure,
+                               gimp_param_spec_int32 ("lower-limit",
+                                                      "lower limit",
+                                                      "Lower limit",
+                                                      0, 255, 0,
+                                                      GIMP_PARAM_READWRITE));
+  gimp_procedure_add_argument (procedure,
+                               gimp_param_spec_int32 ("upper-limit",
+                                                      "upper limit",
+                                                      "Upper limit",
+                                                      0, 255, 0,
+                                                      GIMP_PARAM_READWRITE));
+  gimp_pdb_register_procedure (pdb, procedure);
+  g_object_unref (procedure);
+
+  /*
    * gimp-plug-in-waves
    */
   procedure = gimp_procedure_new (plug_in_waves_invoker);
diff --git a/plug-ins/common/.gitignore b/plug-ins/common/.gitignore
index 9c4ad11..7e21b99 100644
--- a/plug-ins/common/.gitignore
+++ b/plug-ins/common/.gitignore
@@ -198,8 +198,6 @@
 /unit-editor.exe
 /unsharp-mask
 /unsharp-mask.exe
-/value-propagate
-/value-propagate.exe
 /van-gogh-lic
 /van-gogh-lic.exe
 /warp
diff --git a/plug-ins/common/Makefile.am b/plug-ins/common/Makefile.am
index a2d6e97..2be1122 100644
--- a/plug-ins/common/Makefile.am
+++ b/plug-ins/common/Makefile.am
@@ -142,7 +142,6 @@ libexec_PROGRAMS = \
        tile-small \
        unit-editor \
        unsharp-mask \
-       value-propagate \
        van-gogh-lic \
        warp \
        web-browser \
@@ -1907,23 +1906,6 @@ unsharp_mask_LDADD = \
        $(INTLLIBS)             \
        $(unsharp_mask_RC)
 
-value_propagate_SOURCES = \
-       value-propagate.c
-
-value_propagate_LDADD = \
-       $(libgimpui)            \
-       $(libgimpwidgets)       \
-       $(libgimpmodule)        \
-       $(libgimp)              \
-       $(libgimpmath)          \
-       $(libgimpconfig)        \
-       $(libgimpcolor)         \
-       $(libgimpbase)          \
-       $(GTK_LIBS)             \
-       $(RT_LIBS)              \
-       $(INTLLIBS)             \
-       $(value_propagate_RC)
-
 van_gogh_lic_SOURCES = \
        van-gogh-lic.c
 
diff --git a/plug-ins/common/gimprc.common b/plug-ins/common/gimprc.common
index d0d8278..1078c0a 100644
--- a/plug-ins/common/gimprc.common
+++ b/plug-ins/common/gimprc.common
@@ -96,7 +96,6 @@ tile_paper_RC = tile-paper.rc.o
 tile_small_RC = tile-small.rc.o
 unit_editor_RC = unit-editor.rc.o
 unsharp_mask_RC = unsharp-mask.rc.o
-value_propagate_RC = value-propagate.rc.o
 van_gogh_lic_RC = van-gogh-lic.rc.o
 warp_RC = warp.rc.o
 web_browser_RC = web-browser.rc.o
diff --git a/plug-ins/common/plugin-defs.pl b/plug-ins/common/plugin-defs.pl
index 6a480f6..df42d6e 100644
--- a/plug-ins/common/plugin-defs.pl
+++ b/plug-ins/common/plugin-defs.pl
@@ -97,7 +97,6 @@
     'tile-small' => { ui => 1 },
     'unit-editor' => { ui => 1 },
     'unsharp-mask' => { ui => 1 },
-    'value-propagate' => { ui => 1 },
     'van-gogh-lic' => { ui => 1 },
     'warp' => { ui => 1 },
     'web-browser' => { ui => 1 },
diff --git a/po-plug-ins/POTFILES.in b/po-plug-ins/POTFILES.in
index 013d64b..90fc65e 100644
--- a/po-plug-ins/POTFILES.in
+++ b/po-plug-ins/POTFILES.in
@@ -101,7 +101,6 @@ plug-ins/common/tile-paper.c
 plug-ins/common/tile-small.c
 plug-ins/common/unit-editor.c
 plug-ins/common/unsharp-mask.c
-plug-ins/common/value-propagate.c
 plug-ins/common/van-gogh-lic.c
 plug-ins/common/warp.c
 plug-ins/common/web-browser.c
diff --git a/tools/pdbgen/pdb/plug_in_compat.pdb b/tools/pdbgen/pdb/plug_in_compat.pdb
index d8531c9..be942e2 100644
--- a/tools/pdbgen/pdb/plug_in_compat.pdb
+++ b/tools/pdbgen/pdb/plug_in_compat.pdb
@@ -3215,6 +3215,246 @@ CODE
     );
 }
 
+sub plug_in_vpropagate {
+    $blurb = 'Propagate certain colors to neighboring pixels',
+
+    $help = <<'HELP';
+Propagate values of the layer.
+HELP
+
+    &std_pdb_compat('gegl:value-propagate');
+    $date = '2015';
+
+    @inargs = (
+       { name => 'run_mode', type => 'enum GimpRunMode', dead => 1,
+         desc => 'The run mode' },
+       { name => 'image', type => 'image', dead => 1,
+         desc => 'Input image (unused)' },
+       { name => 'drawable', type => 'drawable',
+         desc => 'Input drawable' },
+       { name => 'propagate_mode', type => '0 <= int32 <= 7',
+         desc => 'Propagate mode { 0:white, 1:black, 2:middle value 3:foreground to peak, 4:foreground, 
5:background, 6:opaque, 7:transparent }' },
+       { name => 'propagating_channel', type => 'int32',
+         desc => 'Channels which values are propagated' },
+       { name => 'propagating_rate', type => '0.0 <= float <= 1.0',
+         desc => 'Propagating rate' },
+       { name => 'direction_mask', type => '0 <= int32 <= 15',
+         desc => 'Direction mask' },
+       { name => 'lower_limit', type => '0 <= int32 <= 255',
+         desc => 'Lower limit' },
+       { name => 'upper_limit', type => '0 <= int32 <= 255',
+         desc => 'Upper limit' }
+    );
+
+    %invoke = (
+       code => <<'CODE'
+{
+  if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL,
+                                 GIMP_PDB_ITEM_CONTENT, error) &&
+      gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error))
+    {
+      GeglNode  *node;
+      GimpRGB    color;
+      GeglColor *gegl_color = NULL;
+      gint       gegl_mode  = 0;
+      gboolean   to_left    = (direction_mask & (0x1 << 0)) != 0;
+      gboolean   to_top     = (direction_mask & (0x1 << 1)) != 0;
+      gboolean   to_right   = (direction_mask & (0x1 << 2)) != 0;
+      gboolean   to_bottom  = (direction_mask & (0x1 << 3)) != 0;
+      gboolean   value      = (propagating_channel & (0x1 << 0)) != 0;
+      gboolean   alpha      = (propagating_channel & (0x1 << 1)) != 0;
+
+      switch (propagate_mode)
+        {
+        case 0:
+        case 1:
+        case 2:
+          gegl_mode = propagate_mode;
+          break;
+
+        case 3:
+          gegl_mode = propagate_mode;
+          /* fall thru */
+
+        case 4:
+        case 5:
+          gegl_mode = 4;
+
+          if (propagate_mode != 3)
+            gimp_context_get_foreground (context, &color);
+          else
+            gimp_context_get_background (context, &color);
+
+          gegl_color = gimp_gegl_color_new (&color);
+          break;
+
+        case 6:
+        case 7:
+          gegl_mode = propagate_mode - 1;
+          break;
+        }
+
+      node =
+        gegl_node_new_child (NULL,
+                             "operation",        "gegl:value-propagate",
+                             "mode",             gegl_mode,
+                             "lower-threshold",  (gdouble) lower_limit / 255.0,
+                             "upper-threshold",  (gdouble) upper_limit / 255.0,
+                             "rate",             propagating_rate,
+                             "color",            gegl_color,
+                             "top",              to_top,
+                             "left",             to_left,
+                             "right",            to_right,
+                             "bottom",           to_bottom,
+                             "value",            value,
+                             "alpha",            alpha,
+                             NULL);
+
+      if (gegl_color)
+        g_object_unref (gegl_color);
+
+      gimp_drawable_apply_operation (drawable, progress,
+                                     C_("undo-type", "Value Propagate"),
+                                     node);
+      g_object_unref (node);
+    }
+  else
+    success = FALSE;
+}
+CODE
+    );
+}
+
+sub plug_in_dilate {
+    $blurb = 'Grow lighter areas of the image',
+
+    $help = <<'HELP';
+Dilate image.
+HELP
+
+    &std_pdb_compat('gegl:value-propagate');
+    $date = '2015';
+
+    @inargs = (
+       { name => 'run_mode', type => 'enum GimpRunMode', dead => 1,
+         desc => 'The run mode' },
+       { name => 'image', type => 'image', dead => 1,
+         desc => 'Input image (unused)' },
+       { name => 'drawable', type => 'drawable',
+         desc => 'Input drawable' },
+       { name => 'propagate_mode', type => '0 <= int32 <= 7', dead => 1,
+         desc => 'Propagate mode { 0:white, 1:black, 2:middle value 3:foreground to peak, 4:foreground, 
5:background, 6:opaque, 7:transparent }' },
+       { name => 'propagating_channel', type => 'int32', dead => 1,
+         desc => 'Channels which values are propagated' },
+       { name => 'propagating_rate', type => '0.0 <= float <= 1.0', dead => 1,
+         desc => 'Propagating rate' },
+       { name => 'direction_mask', type => '0 <= int32 <= 15', dead => 1,
+         desc => 'Direction mask' },
+       { name => 'lower_limit', type => '0 <= int32 <= 255', dead => 1,
+         desc => 'Lower limit' },
+       { name => 'upper_limit', type => '0 <= int32 <= 255', dead => 1,
+         desc => 'Upper limit' }
+    );
+
+    %invoke = (
+       code => <<'CODE'
+{
+  if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL,
+                                 GIMP_PDB_ITEM_CONTENT, error) &&
+      gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error))
+    {
+      GeglNode *node =
+        gegl_node_new_child (NULL,
+                             "operation",       "gegl:value-propagate",
+                             "mode",            0, /* GEGL_VALUE_PROPAGATE_MODE_WHITE */
+                             "lower-threshold", 0.0,
+                             "upper-threshold", 1.0,
+                             "rate",            1.0,
+                             "top",             TRUE,
+                             "left",            TRUE,
+                             "right",           TRUE,
+                             "bottom",          TRUE,
+                             "value",           TRUE,
+                             "alpha",           FALSE,
+                             NULL);
+
+      gimp_drawable_apply_operation (drawable, progress,
+                                     C_("undo-type", "Dilate"),
+                                     node);
+      g_object_unref (node);
+    }
+  else
+    success = FALSE;
+}
+CODE
+    );
+}
+
+sub plug_in_erode {
+    $blurb = 'Shrink lighter areas of the image',
+
+    $help = <<'HELP';
+Erode image.
+HELP
+
+    &std_pdb_compat('gegl:value-propagate');
+    $date = '2015';
+
+    @inargs = (
+       { name => 'run_mode', type => 'enum GimpRunMode', dead => 1,
+         desc => 'The run mode' },
+       { name => 'image', type => 'image', dead => 1,
+         desc => 'Input image (unused)' },
+       { name => 'drawable', type => 'drawable',
+         desc => 'Input drawable' },
+       { name => 'propagate_mode', type => '0 <= int32 <= 7', dead => 1,
+         desc => 'Propagate mode { 0:white, 1:black, 2:middle value 3:foreground to peak, 4:foreground, 
5:background, 6:opaque, 7:transparent }' },
+       { name => 'propagating_channel', type => 'int32', dead => 1,
+         desc => 'Channels which values are propagated' },
+       { name => 'propagating_rate', type => '0.0 <= float <= 1.0', dead => 1,
+         desc => 'Propagating rate' },
+       { name => 'direction_mask', type => '0 <= int32 <= 15', dead => 1,
+         desc => 'Direction mask' },
+       { name => 'lower_limit', type => '0 <= int32 <= 255', dead => 1,
+         desc => 'Lower limit' },
+       { name => 'upper_limit', type => '0 <= int32 <= 255', dead => 1,
+         desc => 'Upper limit' }
+    );
+
+    %invoke = (
+       code => <<'CODE'
+{
+  if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL,
+                                 GIMP_PDB_ITEM_CONTENT, error) &&
+      gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error))
+    {
+      GeglNode *node =
+        gegl_node_new_child (NULL,
+                             "operation",       "gegl:value-propagate",
+                             "mode",            1, /* GEGL_VALUE_PROPAGATE_MODE_BLACK */
+                             "lower-threshold", 0.0,
+                             "upper-threshold", 1.0,
+                             "rate",            1.0,
+                             "top",             TRUE,
+                             "left",            TRUE,
+                             "right",           TRUE,
+                             "bottom",          TRUE,
+                             "value",           TRUE,
+                             "alpha",           FALSE,
+                             NULL);
+
+      gimp_drawable_apply_operation (drawable, progress,
+                                     C_("undo-type", "Erode"),
+                                     node);
+      g_object_unref (node);
+    }
+  else
+    success = FALSE;
+}
+CODE
+    );
+}
+
 sub plug_in_waves {
     $blurb = 'Distort the image with waves';
 
@@ -3559,6 +3799,9 @@ CODE
             plug_in_threshold_alpha
             plug_in_video
             plug_in_vinvert
+            plug_in_vpropagate
+            plug_in_dilate
+            plug_in_erode
             plug_in_waves
             plug_in_whirl_pinch);
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]