[gimp] pdb. plug-ins: remove the noise-rgb plug-in and add PDB compat wrappers



commit 64290145a2c79c576ff72d7b02f7f6cfe4f1f48b
Author: Michael Natterer <mitch gimp org>
Date:   Sun May 4 23:42:18 2014 +0200

    pdb. plug-ins: remove the noise-rgb plug-in and add PDB compat wrappers

 app/pdb/internal-procs.c            |    2 +-
 app/pdb/plug-in-compat-cmds.c       |  288 ++++++++++++++++
 plug-ins/common/.gitignore          |    2 -
 plug-ins/common/Makefile.am         |   18 -
 plug-ins/common/gimprc.common       |    1 -
 plug-ins/common/noise-rgb.c         |  624 -----------------------------------
 plug-ins/common/plugin-defs.pl      |    1 -
 po-plug-ins/POTFILES.in             |    2 -
 tools/pdbgen/pdb/plug_in_compat.pdb |  188 ++++++++++-
 9 files changed, 467 insertions(+), 659 deletions(-)
---
diff --git a/app/pdb/internal-procs.c b/app/pdb/internal-procs.c
index 017e0fd..bdcdb30 100644
--- a/app/pdb/internal-procs.c
+++ b/app/pdb/internal-procs.c
@@ -28,7 +28,7 @@
 #include "internal-procs.h"
 
 
-/* 726 procedures registered total */
+/* 728 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 ae08681..15c110b 100644
--- a/app/pdb/plug-in-compat-cmds.c
+++ b/app/pdb/plug-in-compat-cmds.c
@@ -1695,6 +1695,156 @@ plug_in_randomize_slur_invoker (GimpProcedure         *procedure,
 }
 
 static GimpValueArray *
+plug_in_rgb_noise_invoker (GimpProcedure         *procedure,
+                           Gimp                  *gimp,
+                           GimpContext           *context,
+                           GimpProgress          *progress,
+                           const GimpValueArray  *args,
+                           GError               **error)
+{
+  gboolean success = TRUE;
+  GimpDrawable *drawable;
+  gboolean independent;
+  gboolean correlated;
+  gdouble noise_1;
+  gdouble noise_2;
+  gdouble noise_3;
+  gdouble noise_4;
+
+  drawable = gimp_value_get_drawable (gimp_value_array_index (args, 2), gimp);
+  independent = g_value_get_boolean (gimp_value_array_index (args, 3));
+  correlated = g_value_get_boolean (gimp_value_array_index (args, 4));
+  noise_1 = g_value_get_double (gimp_value_array_index (args, 5));
+  noise_2 = g_value_get_double (gimp_value_array_index (args, 6));
+  noise_3 = g_value_get_double (gimp_value_array_index (args, 7));
+  noise_4 = g_value_get_double (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;
+          gdouble   r, g, b, a;
+
+          if (gimp_drawable_is_gray (drawable))
+            {
+              r = noise_1;
+              g = noise_1;
+              b = noise_1;
+              a = noise_2;
+            }
+          else
+            {
+              r = noise_1;
+              g = noise_2;
+              b = noise_3;
+              a = noise_4;
+            }
+
+          node = gegl_node_new_child (NULL,
+                                      "operation",   "gegl:noise-rgb",
+                                      "correlated",  correlated,
+                                      "independent", independent,
+                                      "red",         r,
+                                      "green",       g,
+                                      "blue",        b,
+                                      "alpha",       a,
+                                      "seed",        g_random_int_range (0, G_MAXINT),
+                                      NULL);
+
+          node = wrap_in_gamma_cast (node, drawable);
+
+          gimp_drawable_apply_operation (drawable, progress,
+                                         C_("undo-type", "RGB Noise"),
+                                         node);
+
+          g_object_unref (node);
+        }
+      else
+        success = FALSE;
+    }
+
+  return gimp_procedure_get_return_values (procedure, success,
+                                           error ? *error : NULL);
+}
+
+static GimpValueArray *
+plug_in_noisify_invoker (GimpProcedure         *procedure,
+                         Gimp                  *gimp,
+                         GimpContext           *context,
+                         GimpProgress          *progress,
+                         const GimpValueArray  *args,
+                         GError               **error)
+{
+  gboolean success = TRUE;
+  GimpDrawable *drawable;
+  gboolean independent;
+  gdouble noise_1;
+  gdouble noise_2;
+  gdouble noise_3;
+  gdouble noise_4;
+
+  drawable = gimp_value_get_drawable (gimp_value_array_index (args, 2), gimp);
+  independent = g_value_get_boolean (gimp_value_array_index (args, 3));
+  noise_1 = g_value_get_double (gimp_value_array_index (args, 4));
+  noise_2 = g_value_get_double (gimp_value_array_index (args, 5));
+  noise_3 = g_value_get_double (gimp_value_array_index (args, 6));
+  noise_4 = g_value_get_double (gimp_value_array_index (args, 7));
+
+  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;
+          gdouble   r, g, b, a;
+
+          if (gimp_drawable_is_gray (drawable))
+            {
+              r = noise_1;
+              g = noise_1;
+              b = noise_1;
+              a = noise_2;
+            }
+          else
+            {
+              r = noise_1;
+              g = noise_2;
+              b = noise_3;
+              a = noise_4;
+            }
+
+          node = gegl_node_new_child (NULL,
+                                      "operation",   "gegl:noise-rgb",
+                                      "correlated",  FALSE,
+                                      "independent", independent,
+                                      "red",         r,
+                                      "green",       g,
+                                      "blue",        b,
+                                      "alpha",       a,
+                                      "seed",        g_random_int_range (0, G_MAXINT),
+                                      NULL);
+
+          node = wrap_in_gamma_cast (node, drawable);
+
+          gimp_drawable_apply_operation (drawable, progress,
+                                         C_("undo-type", "Noisify"),
+                                         node);
+
+          g_object_unref (node);
+        }
+      else
+        success = FALSE;
+    }
+
+  return gimp_procedure_get_return_values (procedure, success,
+                                           error ? *error : NULL);
+}
+
+static GimpValueArray *
 plug_in_semiflatten_invoker (GimpProcedure         *procedure,
                              Gimp                  *gimp,
                              GimpContext           *context,
@@ -3730,6 +3880,144 @@ register_plug_in_compat_procs (GimpPDB *pdb)
   g_object_unref (procedure);
 
   /*
+   * gimp-plug-in-rgb-noise
+   */
+  procedure = gimp_procedure_new (plug_in_rgb_noise_invoker);
+  gimp_object_set_static_name (GIMP_OBJECT (procedure),
+                               "plug-in-rgb-noise");
+  gimp_procedure_set_static_strings (procedure,
+                                     "plug-in-rgb-noise",
+                                     "Distort colors by random amounts",
+                                     "Add normally distributed (zero mean) random values to image channels. 
Noise may be additive (uncorrelated) or multiplicative (correlated - also known as speckle noise). For color 
images color channels may be treated together or independently.",
+                                     "Compatibility procedure. Please see 'gegl:noise-rgb' for credits.",
+                                     "Compatibility procedure. Please see 'gegl:noise-rgb' for credits.",
+                                     "2013",
+                                     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,
+                               g_param_spec_boolean ("independent",
+                                                     "independent",
+                                                     "Noise in channels independent",
+                                                     FALSE,
+                                                     GIMP_PARAM_READWRITE));
+  gimp_procedure_add_argument (procedure,
+                               g_param_spec_boolean ("correlated",
+                                                     "correlated",
+                                                     "Noise correlated (i.e. multiplicative not additive)",
+                                                     FALSE,
+                                                     GIMP_PARAM_READWRITE));
+  gimp_procedure_add_argument (procedure,
+                               g_param_spec_double ("noise-1",
+                                                    "noise 1",
+                                                    "Noise in the first channel (red, gray)",
+                                                    0.0, 1.0, 0.0,
+                                                    GIMP_PARAM_READWRITE));
+  gimp_procedure_add_argument (procedure,
+                               g_param_spec_double ("noise-2",
+                                                    "noise 2",
+                                                    "Noise in the second channel (green, gray_alpha)",
+                                                    0.0, 1.0, 0.0,
+                                                    GIMP_PARAM_READWRITE));
+  gimp_procedure_add_argument (procedure,
+                               g_param_spec_double ("noise-3",
+                                                    "noise 3",
+                                                    "Noise in the third channel (blue)",
+                                                    0.0, 1.0, 0.0,
+                                                    GIMP_PARAM_READWRITE));
+  gimp_procedure_add_argument (procedure,
+                               g_param_spec_double ("noise-4",
+                                                    "noise 4",
+                                                    "Noise in the fourth channel (alpha)",
+                                                    0.0, 1.0, 0.0,
+                                                    GIMP_PARAM_READWRITE));
+  gimp_pdb_register_procedure (pdb, procedure);
+  g_object_unref (procedure);
+
+  /*
+   * gimp-plug-in-noisify
+   */
+  procedure = gimp_procedure_new (plug_in_noisify_invoker);
+  gimp_object_set_static_name (GIMP_OBJECT (procedure),
+                               "plug-in-noisify");
+  gimp_procedure_set_static_strings (procedure,
+                                     "plug-in-noisify",
+                                     "Adds random noise to image channels",
+                                     "Add normally distributed random values to image channels. For color 
images each color channel may be treated together or independently.",
+                                     "Compatibility procedure. Please see 'gegl:noise-rgb' for credits.",
+                                     "Compatibility procedure. Please see 'gegl:noise-rgb' for credits.",
+                                     "2013",
+                                     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,
+                               g_param_spec_boolean ("independent",
+                                                     "independent",
+                                                     "Noise in channels independent",
+                                                     FALSE,
+                                                     GIMP_PARAM_READWRITE));
+  gimp_procedure_add_argument (procedure,
+                               g_param_spec_double ("noise-1",
+                                                    "noise 1",
+                                                    "Noise in the first channel (red, gray)",
+                                                    0.0, 1.0, 0.0,
+                                                    GIMP_PARAM_READWRITE));
+  gimp_procedure_add_argument (procedure,
+                               g_param_spec_double ("noise-2",
+                                                    "noise 2",
+                                                    "Noise in the second channel (green, gray_alpha)",
+                                                    0.0, 1.0, 0.0,
+                                                    GIMP_PARAM_READWRITE));
+  gimp_procedure_add_argument (procedure,
+                               g_param_spec_double ("noise-3",
+                                                    "noise 3",
+                                                    "Noise in the third channel (blue)",
+                                                    0.0, 1.0, 0.0,
+                                                    GIMP_PARAM_READWRITE));
+  gimp_procedure_add_argument (procedure,
+                               g_param_spec_double ("noise-4",
+                                                    "noise 4",
+                                                    "Noise in the fourth channel (alpha)",
+                                                    0.0, 1.0, 0.0,
+                                                    GIMP_PARAM_READWRITE));
+  gimp_pdb_register_procedure (pdb, procedure);
+  g_object_unref (procedure);
+
+  /*
    * gimp-plug-in-semiflatten
    */
   procedure = gimp_procedure_new (plug_in_semiflatten_invoker);
diff --git a/plug-ins/common/.gitignore b/plug-ins/common/.gitignore
index 31add96..bf5f77d 100644
--- a/plug-ins/common/.gitignore
+++ b/plug-ins/common/.gitignore
@@ -178,8 +178,6 @@
 /newsprint.exe
 /nl-filter
 /nl-filter.exe
-/noise-rgb
-/noise-rgb.exe
 /noise-solid
 /noise-solid.exe
 /nova
diff --git a/plug-ins/common/Makefile.am b/plug-ins/common/Makefile.am
index b96660f..a7a10df 100644
--- a/plug-ins/common/Makefile.am
+++ b/plug-ins/common/Makefile.am
@@ -132,7 +132,6 @@ libexec_PROGRAMS = \
        metadata \
        newsprint \
        nl-filter \
-       noise-rgb \
        noise-solid \
        nova \
        oilify \
@@ -1744,23 +1743,6 @@ nl_filter_LDADD = \
        $(INTLLIBS)             \
        $(nl_filter_RC)
 
-noise_rgb_SOURCES = \
-       noise-rgb.c
-
-noise_rgb_LDADD = \
-       $(libgimpui)            \
-       $(libgimpwidgets)       \
-       $(libgimpmodule)        \
-       $(libgimp)              \
-       $(libgimpmath)          \
-       $(libgimpconfig)        \
-       $(libgimpcolor)         \
-       $(libgimpbase)          \
-       $(GTK_LIBS)             \
-       $(RT_LIBS)              \
-       $(INTLLIBS)             \
-       $(noise_rgb_RC)
-
 noise_solid_SOURCES = \
        noise-solid.c
 
diff --git a/plug-ins/common/gimprc.common b/plug-ins/common/gimprc.common
index d95a83f..f36ca16 100644
--- a/plug-ins/common/gimprc.common
+++ b/plug-ins/common/gimprc.common
@@ -86,7 +86,6 @@ max_rgb_RC = max-rgb.rc.o
 metadata_RC = metadata.rc.o
 newsprint_RC = newsprint.rc.o
 nl_filter_RC = nl-filter.rc.o
-noise_rgb_RC = noise-rgb.rc.o
 noise_solid_RC = noise-solid.rc.o
 nova_RC = nova.rc.o
 oilify_RC = oilify.rc.o
diff --git a/plug-ins/common/plugin-defs.pl b/plug-ins/common/plugin-defs.pl
index 3e17174..b5da6a1 100644
--- a/plug-ins/common/plugin-defs.pl
+++ b/plug-ins/common/plugin-defs.pl
@@ -87,7 +87,6 @@
     'metadata' => { ui => 1, libs => 'GEXIV2_LIBS', cflags => 'GEXIV2_CFLAGS' },
     'newsprint' => { ui => 1 },
     'nl-filter' => { ui => 1 },
-    'noise-rgb' => { ui => 1 },
     'noise-solid' => { ui => 1 },
     'nova' => { ui => 1 },
     'oilify' => { ui => 1 },
diff --git a/po-plug-ins/POTFILES.in b/po-plug-ins/POTFILES.in
index 233a60f..ba24bba 100644
--- a/po-plug-ins/POTFILES.in
+++ b/po-plug-ins/POTFILES.in
@@ -11,7 +11,6 @@ plug-ins/common/animation-optimize.c
 plug-ins/common/animation-play.c
 plug-ins/common/blinds.c
 plug-ins/common/blur.c
-plug-ins/common/blur-gauss.c
 plug-ins/common/blur-gauss-selective.c
 plug-ins/common/border-average.c
 plug-ins/common/bump-map.c
@@ -95,7 +94,6 @@ plug-ins/common/max-rgb.c
 plug-ins/common/metadata.c
 plug-ins/common/newsprint.c
 plug-ins/common/nl-filter.c
-plug-ins/common/noise-rgb.c
 plug-ins/common/noise-solid.c
 plug-ins/common/nova.c
 plug-ins/common/oilify.c
diff --git a/tools/pdbgen/pdb/plug_in_compat.pdb b/tools/pdbgen/pdb/plug_in_compat.pdb
index 8e1f54f..ea9515b 100644
--- a/tools/pdbgen/pdb/plug_in_compat.pdb
+++ b/tools/pdbgen/pdb/plug_in_compat.pdb
@@ -1804,6 +1804,172 @@ CODE
     );
 }
 
+sub plug_in_rgb_noise {
+    $blurb = 'Distort colors by random amounts';
+
+    $help = <<'HELP';
+Add normally distributed (zero mean) random values to image channels.
+Noise may be additive (uncorrelated) or multiplicative (correlated -
+also known as speckle noise). For color images color channels may be
+treated together or independently.
+HELP
+
+    &std_pdb_compat('gegl:noise-rgb');
+    $date = '2013';
+
+    @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 => 'independent', type => 'boolean',
+          desc => 'Noise in channels independent' },
+        { name => 'correlated', type => 'boolean',
+          desc => 'Noise correlated (i.e. multiplicative not additive)' },
+        { name => 'noise_1', type => '0.0 <= float <= 1.0',
+          desc => 'Noise in the first channel (red, gray)' },
+        { name => 'noise_2', type => '0.0 <= float <= 1.0',
+          desc => 'Noise in the second channel (green, gray_alpha)' },
+        { name => 'noise_3', type => '0.0 <= float <= 1.0',
+          desc => 'Noise in the third channel (blue)' },
+        { name => 'noise_4', type => '0.0 <= float <= 1.0',
+          desc => 'Noise in the fourth channel (alpha)' }
+    );
+
+    %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;
+      gdouble   r, g, b, a;
+
+      if (gimp_drawable_is_gray (drawable))
+        {
+          r = noise_1;
+          g = noise_1;
+          b = noise_1;
+          a = noise_2;
+        }
+      else
+        {
+          r = noise_1;
+          g = noise_2;
+          b = noise_3;
+          a = noise_4;
+        }
+
+      node = gegl_node_new_child (NULL,
+                                  "operation",   "gegl:noise-rgb",
+                                  "correlated",  correlated,
+                                  "independent", independent,
+                                  "red",         r,
+                                  "green",       g,
+                                  "blue",        b,
+                                  "alpha",       a,
+                                  "seed",        g_random_int_range (0, G_MAXINT),
+                                  NULL);
+
+      node = wrap_in_gamma_cast (node, drawable);
+
+      gimp_drawable_apply_operation (drawable, progress,
+                                     C_("undo-type", "RGB Noise"),
+                                     node);
+
+      g_object_unref (node);
+    }
+  else
+    success = FALSE;
+}
+CODE
+    );
+}
+
+sub plug_in_noisify {
+    $blurb = 'Adds random noise to image channels';
+
+    $help = <<'HELP';
+Add normally distributed random values to image channels. For color
+images each color channel may be treated together or independently.
+HELP
+
+    &std_pdb_compat('gegl:noise-rgb');
+    $date = '2013';
+
+    @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 => 'independent', type => 'boolean',
+          desc => 'Noise in channels independent' },
+        { name => 'noise_1', type => '0.0 <= float <= 1.0',
+          desc => 'Noise in the first channel (red, gray)' },
+        { name => 'noise_2', type => '0.0 <= float <= 1.0',
+          desc => 'Noise in the second channel (green, gray_alpha)' },
+        { name => 'noise_3', type => '0.0 <= float <= 1.0',
+          desc => 'Noise in the third channel (blue)' },
+        { name => 'noise_4', type => '0.0 <= float <= 1.0',
+          desc => 'Noise in the fourth channel (alpha)' }
+    );
+
+    %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;
+      gdouble   r, g, b, a;
+
+      if (gimp_drawable_is_gray (drawable))
+        {
+          r = noise_1;
+          g = noise_1;
+          b = noise_1;
+          a = noise_2;
+        }
+      else
+        {
+          r = noise_1;
+          g = noise_2;
+          b = noise_3;
+          a = noise_4;
+        }
+
+      node = gegl_node_new_child (NULL,
+                                  "operation",   "gegl:noise-rgb",
+                                  "correlated",  FALSE,
+                                  "independent", independent,
+                                  "red",         r,
+                                  "green",       g,
+                                  "blue",        b,
+                                  "alpha",       a,
+                                  "seed",        g_random_int_range (0, G_MAXINT),
+                                  NULL);
+
+      node = wrap_in_gamma_cast (node, drawable);
+
+      gimp_drawable_apply_operation (drawable, progress,
+                                     C_("undo-type", "Noisify"),
+                                     node);
+
+      g_object_unref (node);
+    }
+  else
+    success = FALSE;
+}
+CODE
+    );
+}
+
 sub plug_in_semiflatten {
     $blurb = 'Replace partial transparency with the current background color';
 
@@ -2300,13 +2466,13 @@ CODE
             plug_in_c_astretch
             plug_in_colors_channel_mixer
             plug_in_colortoalpha
-           plug_in_cubism
-           plug_in_gauss
-           plug_in_gauss_iir
-           plug_in_gauss_iir2
-           plug_in_gauss_rle
-           plug_in_gauss_rle2
-           plug_in_hsv_noise
+            plug_in_cubism
+            plug_in_gauss
+            plug_in_gauss_iir
+            plug_in_gauss_iir2
+            plug_in_gauss_rle
+            plug_in_gauss_rle2
+            plug_in_hsv_noise
             plug_in_laplace
             plug_in_lens_distortion
             plug_in_make_seamless
@@ -2317,16 +2483,18 @@ CODE
             plug_in_pixelize2
             plug_in_plasma
             plug_in_polar_coords
-           plug_in_red_eye_removal
+            plug_in_red_eye_removal
             plug_in_randomize_hurl
             plug_in_randomize_pick
             plug_in_randomize_slur
+            plug_in_rgb_noise
+            plug_in_noisify
             plug_in_semiflatten
             plug_in_shift
-           plug_in_spread
+            plug_in_spread
             plug_in_threshold_alpha
             plug_in_vinvert
-           plug_in_waves
+            plug_in_waves
             plug_in_whirl_pinch);
 
 %exports = (app => [ procs], lib => []);


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