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



commit c41c2452c56a6528190934a6bc5c2be35e4748ab
Author: Téo Mazars <teomazars gmail com>
Date:   Sat Nov 16 16:49:00 2013 +0100

    app,pdb: add a compatibility wrapper for contrast-stretch-hsv
    
    ... and remove the old plugin

 app/pdb/internal-procs.c               |    2 +-
 app/pdb/plug-in-compat-cmds.c          |   73 +++++++++++
 plug-ins/common/.gitignore             |    2 -
 plug-ins/common/Makefile.am            |   16 ---
 plug-ins/common/contrast-stretch-hsv.c |  216 --------------------------------
 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    |   49 +++++++
 9 files changed, 123 insertions(+), 238 deletions(-)
---
diff --git a/app/pdb/internal-procs.c b/app/pdb/internal-procs.c
index af7bed2..43aea60 100644
--- a/app/pdb/internal-procs.c
+++ b/app/pdb/internal-procs.c
@@ -28,7 +28,7 @@
 #include "internal-procs.h"
 
 
-/* 704 procedures registered total */
+/* 705 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 fc035b6..1833adf 100644
--- a/app/pdb/plug-in-compat-cmds.c
+++ b/app/pdb/plug-in-compat-cmds.c
@@ -258,6 +258,43 @@ plug_in_autocrop_layer_invoker (GimpProcedure         *procedure,
 }
 
 static GimpValueArray *
+plug_in_autostretch_hsv_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-hsv",
+                                 NULL);
+
+          gimp_drawable_apply_operation (drawable, progress,
+                                         C_("undo-type", "Stretch Contrast HSV"),
+                                         node);
+          g_object_unref (node);
+        }
+      else
+        success = FALSE;
+    }
+
+  return gimp_procedure_get_return_values (procedure, success,
+                                           error ? *error : NULL);
+}
+
+static GimpValueArray *
 plug_in_c_astretch_invoker (GimpProcedure         *procedure,
                             Gimp                  *gimp,
                             GimpContext           *context,
@@ -1859,6 +1896,42 @@ register_plug_in_compat_procs (GimpPDB *pdb)
   g_object_unref (procedure);
 
   /*
+   * gimp-plug-in-autostretch-hsv
+   */
+  procedure = gimp_procedure_new (plug_in_autostretch_hsv_invoker);
+  gimp_object_set_static_name (GIMP_OBJECT (procedure),
+                               "plug-in-autostretch-hsv");
+  gimp_procedure_set_static_strings (procedure,
+                                     "plug-in-autostretch-hsv",
+                                     "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 be total crap :). This version differs from Contrast Autostretch in that it works in HSV space, and 
preserves hue.",
+                                     "Compatibility procedure. Please see 'gegl:stretch-contrast-hsv' for 
credits.",
+                                     "Compatibility procedure. Please see 'gegl:stretch-contrast-hsv' 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-c-astretch
    */
   procedure = gimp_procedure_new (plug_in_c_astretch_invoker);
diff --git a/plug-ins/common/.gitignore b/plug-ins/common/.gitignore
index c2b45e0..55a34b4 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-hsv
-/contrast-stretch-hsv.exe
 /convolution-matrix
 /convolution-matrix.exe
 /crop-zealous
diff --git a/plug-ins/common/Makefile.am b/plug-ins/common/Makefile.am
index a9a06f1..6c21e51 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-hsv \
        convolution-matrix \
        crop-zealous \
        curve-bend \
@@ -555,21 +554,6 @@ contrast_retinex_LDADD = \
        $(INTLLIBS)             \
        $(contrast_retinex_RC)
 
-contrast_stretch_hsv_SOURCES = \
-       contrast-stretch-hsv.c
-
-contrast_stretch_hsv_LDADD = \
-       $(libgimp)              \
-       $(libgimpmath)          \
-       $(libgimpconfig)        \
-       $(libgimpcolor)         \
-       $(libgimpbase)          \
-       $(CAIRO_LIBS)           \
-       $(GDK_PIXBUF_LIBS)      \
-       $(RT_LIBS)              \
-       $(INTLLIBS)             \
-       $(contrast_stretch_hsv_RC)
-
 convolution_matrix_SOURCES = \
        convolution-matrix.c
 
diff --git a/plug-ins/common/gimprc.common b/plug-ins/common/gimprc.common
index 5a4d1b3..2ab3a75 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_hsv_RC = contrast-stretch-hsv.rc.o
 convolution_matrix_RC = convolution-matrix.rc.o
 crop_zealous_RC = crop-zealous.rc.o
 curve_bend_RC = curve-bend.rc.o
diff --git a/plug-ins/common/plugin-defs.pl b/plug-ins/common/plugin-defs.pl
index aad39dd..02bfec4 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-hsv' => {},
     'convolution-matrix' => { ui => 1 },
     'crop-zealous' => {},
     'curve-bend' => { ui => 1 },
diff --git a/po-plug-ins/POTFILES.in b/po-plug-ins/POTFILES.in
index 795d544..9e6cf08 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-hsv.c
 plug-ins/common/convolution-matrix.c
 plug-ins/common/crop-zealous.c
 plug-ins/common/curve-bend.c
diff --git a/tools/pdbgen/pdb/plug_in_compat.pdb b/tools/pdbgen/pdb/plug_in_compat.pdb
index c13ec4a..122198c 100644
--- a/tools/pdbgen/pdb/plug_in_compat.pdb
+++ b/tools/pdbgen/pdb/plug_in_compat.pdb
@@ -242,6 +242,54 @@ CODE
     );
 }
 
+sub plug_in_autostretch_hsv {
+    $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 be total crap :).  This version differs from Contrast
+Autostretch in that it works in HSV space, and preserves hue.
+HELP
+
+    &std_pdb_compat('gegl:stretch-contrast-hsv');
+    $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-hsv",
+                             NULL);
+
+      gimp_drawable_apply_operation (drawable, progress,
+                                     C_("undo-type", "Stretch Contrast HSV"),
+                                     node);
+      g_object_unref (node);
+    }
+  else
+    success = FALSE;
+}
+CODE
+    );
+}
+
 sub plug_in_c_astretch {
     $blurb = 'Stretch contrast to cover the maximum possible range';
 
@@ -1850,6 +1898,7 @@ CODE
             plug_in_antialias
             plug_in_autocrop
             plug_in_autocrop_layer
+            plug_in_autostretch_hsv
             plug_in_c_astretch
             plug_in_colors_channel_mixer
             plug_in_colortoalpha


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