[gimp] pdb: Add gimp-selection-flood



commit b52da8a17e2eb01cee3399b6b0e4b660a22f807d
Author: Ell <ell_se yahoo com>
Date:   Sun Jan 24 18:24:51 2016 +0000

    pdb: Add gimp-selection-flood

 app/pdb/internal-procs.c       |    2 +-
 app/pdb/selection-cmds.c       |   45 ++++++++++++++++++++++++++++++++++++++++
 libgimp/gimp.def               |    1 +
 libgimp/gimpselection_pdb.c    |   34 ++++++++++++++++++++++++++++++
 libgimp/gimpselection_pdb.h    |    1 +
 tools/pdbgen/pdb/selection.pdb |   31 ++++++++++++++++++++++++++-
 6 files changed, 112 insertions(+), 2 deletions(-)
---
diff --git a/app/pdb/internal-procs.c b/app/pdb/internal-procs.c
index ab75227..b71520a 100644
--- a/app/pdb/internal-procs.c
+++ b/app/pdb/internal-procs.c
@@ -28,7 +28,7 @@
 #include "internal-procs.h"
 
 
-/* 799 procedures registered total */
+/* 800 procedures registered total */
 
 void
 internal_procs_init (GimpPDB *pdb)
diff --git a/app/pdb/selection-cmds.c b/app/pdb/selection-cmds.c
index 2b2dcdf..a54fd1b 100644
--- a/app/pdb/selection-cmds.c
+++ b/app/pdb/selection-cmds.c
@@ -422,6 +422,28 @@ selection_shrink_invoker (GimpProcedure         *procedure,
 }
 
 static GimpValueArray *
+selection_flood_invoker (GimpProcedure         *procedure,
+                         Gimp                  *gimp,
+                         GimpContext           *context,
+                         GimpProgress          *progress,
+                         const GimpValueArray  *args,
+                         GError               **error)
+{
+  gboolean success = TRUE;
+  GimpImage *image;
+
+  image = gimp_value_get_image (gimp_value_array_index (args, 0), gimp);
+
+  if (success)
+    {
+      gimp_channel_flood (gimp_image_get_mask (image), TRUE);
+    }
+
+  return gimp_procedure_get_return_values (procedure, success,
+                                           error ? *error : NULL);
+}
+
+static GimpValueArray *
 selection_layer_alpha_invoker (GimpProcedure         *procedure,
                                Gimp                  *gimp,
                                GimpContext           *context,
@@ -949,6 +971,29 @@ register_selection_procs (GimpPDB *pdb)
   g_object_unref (procedure);
 
   /*
+   * gimp-selection-flood
+   */
+  procedure = gimp_procedure_new (selection_flood_invoker);
+  gimp_object_set_static_name (GIMP_OBJECT (procedure),
+                               "gimp-selection-flood");
+  gimp_procedure_set_static_strings (procedure,
+                                     "gimp-selection-flood",
+                                     "Flood the image's selection",
+                                     "This procedure floods the selection. Flooding assigns to each pixel of 
the selection mask the minimum of the maxima of all paths from that pixel to the outside, as if the selection 
mask were a height map of a terrain flooded with water.",
+                                     "Ell",
+                                     "Ell",
+                                     "2016",
+                                     NULL);
+  gimp_procedure_add_argument (procedure,
+                               gimp_param_spec_image_id ("image",
+                                                         "image",
+                                                         "The image",
+                                                         pdb->gimp, FALSE,
+                                                         GIMP_PARAM_READWRITE));
+  gimp_pdb_register_procedure (pdb, procedure);
+  g_object_unref (procedure);
+
+  /*
    * gimp-selection-layer-alpha
    */
   procedure = gimp_procedure_new (selection_layer_alpha_invoker);
diff --git a/libgimp/gimp.def b/libgimp/gimp.def
index 62db2c0..a20c383 100644
--- a/libgimp/gimp.def
+++ b/libgimp/gimp.def
@@ -773,6 +773,7 @@ EXPORTS
        gimp_selection_combine
        gimp_selection_feather
        gimp_selection_float
+       gimp_selection_flood
        gimp_selection_grow
        gimp_selection_invert
        gimp_selection_is_empty
diff --git a/libgimp/gimpselection_pdb.c b/libgimp/gimpselection_pdb.c
index 91fa432..488c7a1 100644
--- a/libgimp/gimpselection_pdb.c
+++ b/libgimp/gimpselection_pdb.c
@@ -500,6 +500,40 @@ gimp_selection_shrink (gint32 image_ID,
 }
 
 /**
+ * gimp_selection_flood:
+ * @image_ID: The image.
+ *
+ * Flood the image's selection
+ *
+ * This procedure floods the selection. Flooding assigns to each pixel
+ * of the selection mask the minimum of the maxima of all paths from
+ * that pixel to the outside, as if the selection mask were a height
+ * map of a terrain flooded with water.
+ *
+ * Returns: TRUE on success.
+ *
+ * Since: 2.10
+ **/
+gboolean
+gimp_selection_flood (gint32 image_ID)
+{
+  GimpParam *return_vals;
+  gint nreturn_vals;
+  gboolean success = TRUE;
+
+  return_vals = gimp_run_procedure ("gimp-selection-flood",
+                                    &nreturn_vals,
+                                    GIMP_PDB_IMAGE, image_ID,
+                                    GIMP_PDB_END);
+
+  success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
+
+  gimp_destroy_params (return_vals, nreturn_vals);
+
+  return success;
+}
+
+/**
  * gimp_selection_layer_alpha:
  * @layer_ID: Layer with alpha.
  *
diff --git a/libgimp/gimpselection_pdb.h b/libgimp/gimpselection_pdb.h
index 31a49e2..cd21a90 100644
--- a/libgimp/gimpselection_pdb.h
+++ b/libgimp/gimpselection_pdb.h
@@ -60,6 +60,7 @@ gboolean               gimp_selection_grow        (gint32          image_ID,
                                                    gint            steps);
 gboolean               gimp_selection_shrink      (gint32          image_ID,
                                                    gint            steps);
+gboolean               gimp_selection_flood       (gint32          image_ID);
 GIMP_DEPRECATED_FOR(gimp_image_select_item)
 gboolean               gimp_selection_layer_alpha (gint32          layer_ID);
 GIMP_DEPRECATED_FOR(gimp_image_select_item)
diff --git a/tools/pdbgen/pdb/selection.pdb b/tools/pdbgen/pdb/selection.pdb
index 4722e58..dc5def8 100644
--- a/tools/pdbgen/pdb/selection.pdb
+++ b/tools/pdbgen/pdb/selection.pdb
@@ -423,6 +423,35 @@ CODE
     );
 }
 
+sub selection_flood {
+    $blurb = "Flood the image's selection";
+
+    $help .= <<'HELP';
+This procedure floods the selection. Flooding assigns to each pixel
+of the selection mask the minimum of the maxima of all paths from
+that pixel to the outside, as if the selection mask were a height
+map of a terrain flooded with water.
+HELP
+
+    $author = 'Ell';
+    $copyright = 'Ell';
+    $date = '2016';
+    $since = '2.10';
+
+    @inargs = (
+       { name => 'image', type => 'image',
+         desc => 'The image' }
+    );
+
+    %invoke = (
+       code => <<'CODE'
+{
+  gimp_channel_flood (gimp_image_get_mask (image), TRUE);
+}
+CODE
+    );
+}
+
 sub selection_layer_alpha {
     &std_pdb_deprecated ('gimp-image-select-item');
 
@@ -534,7 +563,7 @@ CODE
            selection_translate selection_float
            selection_invert selection_sharpen selection_all selection_none
            selection_feather selection_border selection_grow selection_shrink
-           selection_layer_alpha selection_load selection_save
+           selection_flood selection_layer_alpha selection_load selection_save
            selection_combine);
 
 %exports = (app => [ procs], lib => [ procs]);


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