[gimp] app,pdb: add a compatibility wrapper to contrast-stretch



commit 120e9ccf39214ea380c5d70ba9fcc2faccef5144
Author: Téo Mazars <teomazars gmail com>
Date:   Fri Nov 15 19:10:42 2013 +0100

    app,pdb: add a compatibility wrapper to contrast-stretch
    
    ... and remove the old plug-in

 app/pdb/internal-procs.c            |    2 +-
 app/pdb/plug-in-compat-cmds.c       |   75 +++++++++++
 plug-ins/common/.gitignore          |    2 -
 plug-ins/common/Makefile.am         |   16 ---
 plug-ins/common/contrast-stretch.c  |  251 -----------------------------------
 plug-ins/common/gimprc.common       |    1 -
 plug-ins/common/plugin-defs.pl      |    1 -
 po-plug-ins/POTFILES.in             |    1 -
 tools/pdbgen/pdb/plug_in_compat.pdb |   50 +++++++
 9 files changed, 126 insertions(+), 273 deletions(-)
---
diff --git a/app/pdb/internal-procs.c b/app/pdb/internal-procs.c
index 5dada82..af7bed2 100644
--- a/app/pdb/internal-procs.c
+++ b/app/pdb/internal-procs.c
@@ -28,7 +28,7 @@
 #include "internal-procs.h"
 
 
-/* 703 procedures registered total */
+/* 704 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 7b3d9fe..fc035b6 100644
--- a/app/pdb/plug-in-compat-cmds.c
+++ b/app/pdb/plug-in-compat-cmds.c
@@ -258,6 +258,45 @@ plug_in_autocrop_layer_invoker (GimpProcedure         *procedure,
 }
 
 static GimpValueArray *
+plug_in_c_astretch_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:stretch-contrast",
+                                 "keep-colors", (gboolean) FALSE,
+                                 NULL);
+
+          gimp_drawable_apply_operation (drawable, progress,
+                                         C_("undo-type", "Stretch Contrast"),
+                                         node);
+
+          g_object_unref (node);
+        }
+      else
+        success = FALSE;
+    }
+
+  return gimp_procedure_get_return_values (procedure, success,
+                                           error ? *error : NULL);
+}
+
+static GimpValueArray *
 plug_in_colors_channel_mixer_invoker (GimpProcedure         *procedure,
                                       Gimp                  *gimp,
                                       GimpContext           *context,
@@ -1820,6 +1859,42 @@ register_plug_in_compat_procs (GimpPDB *pdb)
   g_object_unref (procedure);
 
   /*
+   * gimp-plug-in-c-astretch
+   */
+  procedure = gimp_procedure_new (plug_in_c_astretch_invoker);
+  gimp_object_set_static_name (GIMP_OBJECT (procedure),
+                               "plug-in-c-astretch");
+  gimp_procedure_set_static_strings (procedure,
+                                     "plug-in-c-astretch",
+                                     "Stretch contrast to cover the maximum possible range",
+                                     "This simple plug-in does an automatic contrast stretch. For each 
channel in the image, it finds the minimum and maximum values... it uses those values to stretch the 
individual histograms to the full contrast range. For some images it may do just what you want; for others it 
may not work that well.",
+                                     "Compatibility procedure. Please see 'gegl:stretch-contrast' for 
credits.",
+                                     "Compatibility procedure. Please see 'gegl:stretch-contrast' 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_pdb_register_procedure (pdb, procedure);
+  g_object_unref (procedure);
+
+  /*
    * gimp-plug-in-colors-channel-mixer
    */
   procedure = gimp_procedure_new (plug_in_colors_channel_mixer_invoker);
diff --git a/plug-ins/common/.gitignore b/plug-ins/common/.gitignore
index 917b863..c2b45e0 100644
--- a/plug-ins/common/.gitignore
+++ b/plug-ins/common/.gitignore
@@ -44,8 +44,6 @@
 /contrast-normalize.exe
 /contrast-retinex
 /contrast-retinex.exe
-/contrast-stretch
-/contrast-stretch.exe
 /contrast-stretch-hsv
 /contrast-stretch-hsv.exe
 /convolution-matrix
diff --git a/plug-ins/common/Makefile.am b/plug-ins/common/Makefile.am
index 85fd3c7..a9a06f1 100644
--- a/plug-ins/common/Makefile.am
+++ b/plug-ins/common/Makefile.am
@@ -65,7 +65,6 @@ libexec_PROGRAMS = \
        compose \
        contrast-normalize \
        contrast-retinex \
-       contrast-stretch \
        contrast-stretch-hsv \
        convolution-matrix \
        crop-zealous \
@@ -556,21 +555,6 @@ contrast_retinex_LDADD = \
        $(INTLLIBS)             \
        $(contrast_retinex_RC)
 
-contrast_stretch_SOURCES = \
-       contrast-stretch.c
-
-contrast_stretch_LDADD = \
-       $(libgimp)              \
-       $(libgimpmath)          \
-       $(libgimpconfig)        \
-       $(libgimpcolor)         \
-       $(libgimpbase)          \
-       $(CAIRO_LIBS)           \
-       $(GDK_PIXBUF_LIBS)      \
-       $(RT_LIBS)              \
-       $(INTLLIBS)             \
-       $(contrast_stretch_RC)
-
 contrast_stretch_hsv_SOURCES = \
        contrast-stretch-hsv.c
 
diff --git a/plug-ins/common/gimprc.common b/plug-ins/common/gimprc.common
index 59c8454..5a4d1b3 100644
--- a/plug-ins/common/gimprc.common
+++ b/plug-ins/common/gimprc.common
@@ -19,7 +19,6 @@ colormap_remap_RC = colormap-remap.rc.o
 compose_RC = compose.rc.o
 contrast_normalize_RC = contrast-normalize.rc.o
 contrast_retinex_RC = contrast-retinex.rc.o
-contrast_stretch_RC = contrast-stretch.rc.o
 contrast_stretch_hsv_RC = contrast-stretch-hsv.rc.o
 convolution_matrix_RC = convolution-matrix.rc.o
 crop_zealous_RC = crop-zealous.rc.o
diff --git a/plug-ins/common/plugin-defs.pl b/plug-ins/common/plugin-defs.pl
index 2ddc716..aad39dd 100644
--- a/plug-ins/common/plugin-defs.pl
+++ b/plug-ins/common/plugin-defs.pl
@@ -20,7 +20,6 @@
     'compose' => { ui => 1, gegl => 1 },
     'contrast-normalize' => {},
     'contrast-retinex' => { ui => 1 },
-    'contrast-stretch' => {},
     'contrast-stretch-hsv' => {},
     'convolution-matrix' => { ui => 1 },
     'crop-zealous' => {},
diff --git a/po-plug-ins/POTFILES.in b/po-plug-ins/POTFILES.in
index 7b02b6f..795d544 100644
--- a/po-plug-ins/POTFILES.in
+++ b/po-plug-ins/POTFILES.in
@@ -27,7 +27,6 @@ plug-ins/common/colormap-remap.c
 plug-ins/common/compose.c
 plug-ins/common/contrast-normalize.c
 plug-ins/common/contrast-retinex.c
-plug-ins/common/contrast-stretch.c
 plug-ins/common/contrast-stretch-hsv.c
 plug-ins/common/convolution-matrix.c
 plug-ins/common/crop-zealous.c
diff --git a/tools/pdbgen/pdb/plug_in_compat.pdb b/tools/pdbgen/pdb/plug_in_compat.pdb
index 7c25598..c13ec4a 100644
--- a/tools/pdbgen/pdb/plug_in_compat.pdb
+++ b/tools/pdbgen/pdb/plug_in_compat.pdb
@@ -242,6 +242,55 @@ CODE
     );
 }
 
+sub plug_in_c_astretch {
+    $blurb = 'Stretch contrast to cover the maximum possible range';
+
+    $help = <<'HELP';
+This simple plug-in does an automatic contrast stretch.  For each
+channel in the image, it finds the minimum and maximum values... it
+uses those values to stretch the individual histograms to the full
+contrast range.  For some images it may do just what you want; for
+others it may not work that well.
+HELP
+
+    &std_pdb_compat('gegl:stretch-contrast');
+    $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' }
+    );
+
+    %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:stretch-contrast",
+                             "keep-colors", (gboolean) FALSE,
+                             NULL);
+
+      gimp_drawable_apply_operation (drawable, progress,
+                                     C_("undo-type", "Stretch Contrast"),
+                                     node);
+
+      g_object_unref (node);
+    }
+  else
+    success = FALSE;
+}
+CODE
+    );
+}
+
 sub plug_in_colors_channel_mixer {
     $blurb = 'Alter colors by mixing RGB Channels';
 
@@ -1801,6 +1850,7 @@ CODE
             plug_in_antialias
             plug_in_autocrop
             plug_in_autocrop_layer
+            plug_in_c_astretch
             plug_in_colors_channel_mixer
             plug_in_colortoalpha
            plug_in_cubism


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