[gimp] Replace the threshold-slpha plug-in by a GEGL operation



commit f24445efbcc5760c7f26d937fac5b334f0a6ab4b
Author: Michael Natterer <mitch gimp org>
Date:   Fri May 4 17:59:36 2012 +0200

    Replace the threshold-slpha plug-in by a GEGL operation

 app/actions/filters-actions.c          |    7 +
 app/gegl/Makefile.am                   |    2 +
 app/gegl/gimp-gegl.c                   |    2 +
 app/gegl/gimpoperationsetalpha.h       |    3 +-
 app/gegl/gimpoperationthresholdalpha.c |  173 ++++++++++++++++++
 app/gegl/gimpoperationthresholdalpha.h |   56 ++++++
 app/pdb/internal-procs.c               |    2 +-
 app/pdb/plug-in-compat-cmds.c          |   83 +++++++++
 menus/image-menu.xml.in                |    1 +
 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/threshold-alpha.c      |  302 --------------------------------
 po-plug-ins/POTFILES.in                |    1 -
 tools/pdbgen/pdb/plug_in_compat.pdb    |   48 +++++
 16 files changed, 374 insertions(+), 328 deletions(-)
---
diff --git a/app/actions/filters-actions.c b/app/actions/filters-actions.c
index 32632e0..41c4b83 100644
--- a/app/actions/filters-actions.c
+++ b/app/actions/filters-actions.c
@@ -68,6 +68,12 @@ static const GimpStringActionEntry filters_actions[] =
     NC_("filters-action", "Convert image to or from polar coordinates"),
     "gegl:polar-coordinates",
     NULL /* FIXME GIMP_HELP_FILTER_POLAR_COORDINATES */ },
+
+  { "filters-threshold-alpha", GIMP_STOCK_GEGL,
+    NC_("filters-action", "_Threshold Alpha..."), NULL,
+    NC_("filters-action", "Make transparency all-or-nothing"),
+    "gimp:threshold-alpha",
+    NULL /* FIXME GIMP_HELP_FILTER_POLAR_COORDINATES */ },
 };
 
 void
@@ -122,6 +128,7 @@ filters_actions_update (GimpActionGroup *group,
   SET_SENSITIVE ("filters-gaussian-blur",     writable);
   SET_SENSITIVE ("filters-pixelize",          writable);
   SET_SENSITIVE ("filters-polar-coordinates", writable);
+  SET_SENSITIVE ("filters-threshold-alpha",   writable && alpha);
 
 #undef SET_SENSITIVE
 }
diff --git a/app/gegl/Makefile.am b/app/gegl/Makefile.am
index ead06f0..03dc765 100644
--- a/app/gegl/Makefile.am
+++ b/app/gegl/Makefile.am
@@ -78,6 +78,8 @@ libappgegl_a_sources = \
 	gimpoperationshapeburst.h		\
 	gimpoperationshrink.c			\
 	gimpoperationshrink.h			\
+	gimpoperationthresholdalpha.c		\
+	gimpoperationthresholdalpha.h		\
 	\
 	gimpoperationpointfilter.c		\
 	gimpoperationpointfilter.h		\
diff --git a/app/gegl/gimp-gegl.c b/app/gegl/gimp-gegl.c
index b37ec629..2e78d24 100644
--- a/app/gegl/gimp-gegl.c
+++ b/app/gegl/gimp-gegl.c
@@ -43,6 +43,7 @@
 #include "gimpoperationsetalpha.h"
 #include "gimpoperationshapeburst.h"
 #include "gimpoperationshrink.h"
+#include "gimpoperationthresholdalpha.h"
 
 #include "gimpoperationbrightnesscontrast.h"
 #include "gimpoperationcolorbalance.h"
@@ -125,6 +126,7 @@ gimp_gegl_init (Gimp *gimp)
   g_type_class_ref (GIMP_TYPE_OPERATION_SET_ALPHA);
   g_type_class_ref (GIMP_TYPE_OPERATION_SHAPEBURST);
   g_type_class_ref (GIMP_TYPE_OPERATION_SHRINK);
+  g_type_class_ref (GIMP_TYPE_OPERATION_THRESHOLD_ALPHA);
 
   g_type_class_ref (GIMP_TYPE_OPERATION_BRIGHTNESS_CONTRAST);
   g_type_class_ref (GIMP_TYPE_OPERATION_COLOR_BALANCE);
diff --git a/app/gegl/gimpoperationsetalpha.h b/app/gegl/gimpoperationsetalpha.h
index c56f85b..e48e376 100644
--- a/app/gegl/gimpoperationsetalpha.h
+++ b/app/gegl/gimpoperationsetalpha.h
@@ -23,7 +23,6 @@
 
 
 #include <gegl-plugin.h>
-#include <operation/gegl-operation-point-filter.h>
 
 
 #define GIMP_TYPE_OPERATION_SET_ALPHA            (gimp_operation_set_alpha_get_type ())
@@ -41,7 +40,7 @@ struct _GimpOperationSetAlpha
 {
   GeglOperationPointComposer  parent_instance;
 
-  gdouble                   value;
+  gdouble                     value;
 };
 
 struct _GimpOperationSetAlphaClass
diff --git a/app/gegl/gimpoperationthresholdalpha.c b/app/gegl/gimpoperationthresholdalpha.c
new file mode 100644
index 0000000..7a530bb
--- /dev/null
+++ b/app/gegl/gimpoperationthresholdalpha.c
@@ -0,0 +1,173 @@
+/* GIMP - The GNU Image Manipulation Program
+ * Copyright (C) 1995 Spencer Kimball and Peter Mattis
+ *
+ * gimpoperationthresholdalpha.c
+ * Copyright (C) 2012 Michael Natterer <mitch gimp org>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Ported from the threshold-alpha plug-in
+ * Copyright (C) 1997 Shuji Narazaki <narazaki InetQ or jp>
+ */
+
+#include "config.h"
+
+#include <gegl.h>
+
+#include "gimp-gegl-types.h"
+
+#include "gimpoperationthresholdalpha.h"
+
+
+enum
+{
+  PROP_0,
+  PROP_VALUE
+};
+
+
+static void       gimp_operation_threshold_alpha_get_property (GObject             *object,
+                                                               guint                property_id,
+                                                               GValue              *value,
+                                                               GParamSpec          *pspec);
+static void       gimp_operation_threshold_alpha_set_property (GObject             *object,
+                                                               guint                property_id,
+                                                               const GValue        *value,
+                                                               GParamSpec          *pspec);
+
+static void       gimp_operation_threshold_alpha_prepare      (GeglOperation       *operation);
+static gboolean   gimp_operation_threshold_alpha_process      (GeglOperation       *operation,
+                                                               void                *in_buf,
+                                                               void                *out_buf,
+                                                               glong                samples,
+                                                               const GeglRectangle *roi,
+                                                               gint                 level);
+
+
+G_DEFINE_TYPE (GimpOperationThresholdAlpha, gimp_operation_threshold_alpha,
+               GEGL_TYPE_OPERATION_POINT_FILTER)
+
+#define parent_class gimp_operation_threshold_alpha_parent_class
+
+
+static void
+gimp_operation_threshold_alpha_class_init (GimpOperationThresholdAlphaClass *klass)
+{
+  GObjectClass                  *object_class    = G_OBJECT_CLASS (klass);
+  GeglOperationClass            *operation_class = GEGL_OPERATION_CLASS (klass);
+  GeglOperationPointFilterClass *point_class     = GEGL_OPERATION_POINT_FILTER_CLASS (klass);
+
+  object_class->set_property = gimp_operation_threshold_alpha_set_property;
+  object_class->get_property = gimp_operation_threshold_alpha_get_property;
+
+  gegl_operation_class_set_keys (operation_class,
+                                 "name",        "gimp:threshold-alpha",
+                                 "categories",  "color",
+                                 "description", "Threshold a buffer's alpha channel to a value",
+                                 NULL);
+
+  operation_class->prepare = gimp_operation_threshold_alpha_prepare;
+
+  point_class->process     = gimp_operation_threshold_alpha_process;
+
+  g_object_class_install_property (object_class, PROP_VALUE,
+                                   g_param_spec_double ("value",
+                                                        "Value",
+                                                        "The alpha value",
+                                                        0.0, 1.0, 0.5,
+                                                        G_PARAM_READWRITE |
+                                                        G_PARAM_CONSTRUCT));
+}
+
+static void
+gimp_operation_threshold_alpha_init (GimpOperationThresholdAlpha *self)
+{
+}
+
+static void
+gimp_operation_threshold_alpha_get_property (GObject    *object,
+                                             guint       property_id,
+                                             GValue     *value,
+                                             GParamSpec *pspec)
+{
+  GimpOperationThresholdAlpha *self = GIMP_OPERATION_THRESHOLD_ALPHA (object);
+
+  switch (property_id)
+    {
+    case PROP_VALUE:
+      g_value_set_double (value, self->value);
+      break;
+
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+      break;
+    }
+}
+
+static void
+gimp_operation_threshold_alpha_set_property (GObject      *object,
+                                             guint         property_id,
+                                             const GValue *value,
+                                             GParamSpec   *pspec)
+{
+  GimpOperationThresholdAlpha *self = GIMP_OPERATION_THRESHOLD_ALPHA (object);
+
+  switch (property_id)
+    {
+    case PROP_VALUE:
+      self->value = g_value_get_double (value);
+      break;
+
+   default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+      break;
+    }
+}
+
+static void
+gimp_operation_threshold_alpha_prepare (GeglOperation *operation)
+{
+  gegl_operation_set_format (operation, "input",  babl_format ("RGBA float"));
+  gegl_operation_set_format (operation, "output", babl_format ("RGBA float"));
+}
+
+static gboolean
+gimp_operation_threshold_alpha_process (GeglOperation       *operation,
+                                        void                *in_buf,
+                                        void                *out_buf,
+                                        glong                samples,
+                                        const GeglRectangle *roi,
+                                        gint                 level)
+{
+  GimpOperationThresholdAlpha *self = GIMP_OPERATION_THRESHOLD_ALPHA (operation);
+  gfloat                      *src  = in_buf;
+  gfloat                      *dest = out_buf;
+
+  while (samples--)
+    {
+      dest[RED]   = src[RED];
+      dest[GREEN] = src[GREEN];
+      dest[BLUE]  = src[BLUE];
+
+      if (src[ALPHA] > self->value)
+        dest[ALPHA] = 1.0;
+      else
+        dest[ALPHA] = 0.0;
+
+      src  += 4;
+      dest += 4;
+    }
+
+  return TRUE;
+}
diff --git a/app/gegl/gimpoperationthresholdalpha.h b/app/gegl/gimpoperationthresholdalpha.h
new file mode 100644
index 0000000..24cdf0c
--- /dev/null
+++ b/app/gegl/gimpoperationthresholdalpha.h
@@ -0,0 +1,56 @@
+/* GIMP - The GNU Image Manipulation Program
+ * Copyright (C) 1995 Spencer Kimball and Peter Mattis
+ *
+ * gimpoperationthresholdalpha.h
+ * Copyright (C) 2012 Michael Natterer <mitch gimp org>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __GIMP_OPERATION_THRESHOLD_ALPHA_H__
+#define __GIMP_OPERATION_THRESHOLD_ALPHA_H__
+
+
+#include <gegl-plugin.h>
+#include <operation/gegl-operation-point-filter.h>
+
+
+#define GIMP_TYPE_OPERATION_THRESHOLD_ALPHA            (gimp_operation_threshold_alpha_get_type ())
+#define GIMP_OPERATION_THRESHOLD_ALPHA(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_OPERATION_THRESHOLD_ALPHA, GimpOperationThresholdAlpha))
+#define GIMP_OPERATION_THRESHOLD_ALPHA_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass),  GIMP_TYPE_OPERATION_THRESHOLD_ALPHA, GimpOperationThresholdAlphaClass))
+#define GIMP_IS_OPERATION_THRESHOLD_ALPHA(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_OPERATION_THRESHOLD_ALPHA))
+#define GIMP_IS_OPERATION_THRESHOLD_ALPHA_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass),  GIMP_TYPE_OPERATION_THRESHOLD_ALPHA))
+#define GIMP_OPERATION_THRESHOLD_ALPHA_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj),  GIMP_TYPE_OPERATION_THRESHOLD_ALPHA, GimpOperationThresholdAlphaClass))
+
+
+typedef struct _GimpOperationThresholdAlpha      GimpOperationThresholdAlpha;
+typedef struct _GimpOperationThresholdAlphaClass GimpOperationThresholdAlphaClass;
+
+struct _GimpOperationThresholdAlpha
+{
+  GeglOperationPointFilter  parent_instance;
+
+  gdouble                   value;
+};
+
+struct _GimpOperationThresholdAlphaClass
+{
+  GeglOperationPointFilterClass  parent_class;
+};
+
+
+GType   gimp_operation_threshold_alpha_get_type (void) G_GNUC_CONST;
+
+
+#endif /* __GIMP_OPERATION_THRESHOLD_ALPHA_H__ */
diff --git a/app/pdb/internal-procs.c b/app/pdb/internal-procs.c
index 35daa18..d146c38 100644
--- a/app/pdb/internal-procs.c
+++ b/app/pdb/internal-procs.c
@@ -28,7 +28,7 @@
 #include "internal-procs.h"
 
 
-/* 674 procedures registered total */
+/* 675 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 27df4a4..aca986a 100644
--- a/app/pdb/plug-in-compat-cmds.c
+++ b/app/pdb/plug-in-compat-cmds.c
@@ -226,6 +226,47 @@ plug_in_polar_coords_invoker (GimpProcedure      *procedure,
 }
 
 static GimpValueArray *
+plug_in_threshold_alpha_invoker (GimpProcedure      *procedure,
+                                 Gimp                  *gimp,
+                                 GimpContext           *context,
+                                 GimpProgress          *progress,
+                                 const GimpValueArray  *args,
+                                 GError               **error)
+{
+  gboolean success = TRUE;
+  GimpDrawable *drawable;
+  gint32 threshold;
+
+  drawable = gimp_value_get_drawable (gimp_value_array_index (args, 2), gimp);
+  threshold = g_value_get_int (gimp_value_array_index (args, 3));
+
+  if (success)
+    {
+      if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, TRUE, error) &&
+          gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error) &&
+          gimp_drawable_has_alpha (drawable))
+        {
+          GeglNode *node =
+            gegl_node_new_child (NULL,
+                                 "operation", "gimp:threshold-alpha",
+                                 "value",     threshold / 255.0,
+                                 NULL);
+
+          gimp_drawable_apply_operation (drawable, progress,
+                                         C_("undo-type", "Threshold Alpha"),
+                                         node);
+
+          g_object_unref (node);
+        }
+      else
+        success = FALSE;
+    }
+
+  return gimp_procedure_get_return_values (procedure, success,
+                                           error ? *error : NULL);
+}
+
+static GimpValueArray *
 plug_in_vinvert_invoker (GimpProcedure      *procedure,
                          Gimp                  *gimp,
                          GimpContext           *context,
@@ -467,6 +508,48 @@ register_plug_in_compat_procs (GimpPDB *pdb)
   g_object_unref (procedure);
 
   /*
+   * gimp-plug-in-threshold-alpha
+   */
+  procedure = gimp_procedure_new (plug_in_threshold_alpha_invoker);
+  gimp_object_set_static_name (GIMP_OBJECT (procedure),
+                               "plug-in-threshold-alpha");
+  gimp_procedure_set_static_strings (procedure,
+                                     "plug-in-threshold-alpha",
+                                     "Make transparency all-or-nothing",
+                                     "Make transparency all-or-nothing.",
+                                     "Spencer Kimball & Peter Mattis",
+                                     "Spencer Kimball & Peter Mattis",
+                                     "1997",
+                                     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 ("threshold",
+                                                      "threshold",
+                                                      "Threshold",
+                                                      0, 255, 0,
+                                                      GIMP_PARAM_READWRITE));
+  gimp_pdb_register_procedure (pdb, procedure);
+  g_object_unref (procedure);
+
+  /*
    * gimp-plug-in-vinvert
    */
   procedure = gimp_procedure_new (plug_in_vinvert_invoker);
diff --git a/menus/image-menu.xml.in b/menus/image-menu.xml.in
index fbdc027..bcb3eac 100644
--- a/menus/image-menu.xml.in
+++ b/menus/image-menu.xml.in
@@ -431,6 +431,7 @@
           <menuitem action="layers-alpha-add" />
           <menuitem action="layers-alpha-remove" />
           <menuitem action="filters-color-to-alpha" />
+          <menuitem action="filters-threshold-alpha" />
         </placeholder>
         <separator />
         <placeholder name="Selection">
diff --git a/plug-ins/common/.gitignore b/plug-ins/common/.gitignore
index 128033e..c9b9279 100644
--- a/plug-ins/common/.gitignore
+++ b/plug-ins/common/.gitignore
@@ -254,8 +254,6 @@
 /sparkle.exe
 /sphere-designer
 /sphere-designer.exe
-/threshold-alpha
-/threshold-alpha.exe
 /tile
 /tile.exe
 /tile-glass
diff --git a/plug-ins/common/Makefile.am b/plug-ins/common/Makefile.am
index abd7a1c..b870a59 100644
--- a/plug-ins/common/Makefile.am
+++ b/plug-ins/common/Makefile.am
@@ -170,7 +170,6 @@ libexec_PROGRAMS = \
 	softglow \
 	sparkle \
 	sphere-designer \
-	threshold-alpha \
 	tile \
 	tile-glass \
 	tile-paper \
@@ -2366,23 +2365,6 @@ sphere_designer_LDADD = \
 	$(INTLLIBS)		\
 	$(sphere_designer_RC)
 
-threshold_alpha_SOURCES = \
-	threshold-alpha.c
-
-threshold_alpha_LDADD = \
-	$(libgimpui)		\
-	$(libgimpwidgets)	\
-	$(libgimpmodule)	\
-	$(libgimp)		\
-	$(libgimpmath)		\
-	$(libgimpconfig)	\
-	$(libgimpcolor)		\
-	$(libgimpbase)		\
-	$(GTK_LIBS)		\
-	$(RT_LIBS)		\
-	$(INTLLIBS)		\
-	$(threshold_alpha_RC)
-
 tile_SOURCES = \
 	tile.c
 
diff --git a/plug-ins/common/gimprc.common b/plug-ins/common/gimprc.common
index 3445361..1f2792f 100644
--- a/plug-ins/common/gimprc.common
+++ b/plug-ins/common/gimprc.common
@@ -124,7 +124,6 @@ smooth_palette_RC = smooth-palette.rc.o
 softglow_RC = softglow.rc.o
 sparkle_RC = sparkle.rc.o
 sphere_designer_RC = sphere-designer.rc.o
-threshold_alpha_RC = threshold-alpha.rc.o
 tile_RC = tile.rc.o
 tile_glass_RC = tile-glass.rc.o
 tile_paper_RC = tile-paper.rc.o
diff --git a/plug-ins/common/plugin-defs.pl b/plug-ins/common/plugin-defs.pl
index 3ca2188..5394dc3 100644
--- a/plug-ins/common/plugin-defs.pl
+++ b/plug-ins/common/plugin-defs.pl
@@ -125,7 +125,6 @@
     'softglow' => { ui => 1 },
     'sparkle' => { ui => 1 },
     'sphere-designer' => { ui => 1 },
-    'threshold-alpha' => { ui => 1 },
     'tile' => { ui => 1 },
     'tile-glass' => { ui => 1 },
     'tile-paper' => { ui => 1 },
diff --git a/po-plug-ins/POTFILES.in b/po-plug-ins/POTFILES.in
index 360e6b8..3e275e5 100644
--- a/po-plug-ins/POTFILES.in
+++ b/po-plug-ins/POTFILES.in
@@ -132,7 +132,6 @@ plug-ins/common/smooth-palette.c
 plug-ins/common/softglow.c
 plug-ins/common/sparkle.c
 plug-ins/common/sphere-designer.c
-plug-ins/common/threshold-alpha.c
 plug-ins/common/tile.c
 plug-ins/common/tile-glass.c
 plug-ins/common/tile-paper.c
diff --git a/tools/pdbgen/pdb/plug_in_compat.pdb b/tools/pdbgen/pdb/plug_in_compat.pdb
index d933e4c..07cc577 100644
--- a/tools/pdbgen/pdb/plug_in_compat.pdb
+++ b/tools/pdbgen/pdb/plug_in_compat.pdb
@@ -224,6 +224,53 @@ CODE
     );
 }
 
+sub plug_in_threshold_alpha {
+    $blurb = 'Make transparency all-or-nothing';
+
+    $help = <<'HELP';
+Make transparency all-or-nothing.
+HELP
+
+    &std_pdb_misc;
+    $date = '1997';
+
+    @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 => 'threshold', type => '0 <= int32 <= 255',
+	  desc => 'Threshold' }
+    );
+
+    %invoke = (
+	code => <<'CODE'
+{
+  if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, TRUE, error) &&
+      gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error) &&
+      gimp_drawable_has_alpha (drawable))
+    {
+      GeglNode *node =
+        gegl_node_new_child (NULL,
+                             "operation", "gimp:threshold-alpha",
+                             "value",     threshold / 255.0,
+                             NULL);
+
+      gimp_drawable_apply_operation (drawable, progress,
+                                     C_("undo-type", "Threshold Alpha"),
+                                     node);
+
+      g_object_unref (node);
+    }
+  else
+    success = FALSE;
+}
+CODE
+    );
+}
+
 sub plug_in_vinvert {
     $blurb = 'Invert the brightness of each pixel';
 
@@ -283,6 +330,7 @@ CODE
             plug_in_pixelize
             plug_in_pixelize2
             plug_in_polar_coords
+	    plug_in_threshold_alpha
             plug_in_vinvert);
 
 %exports = (app => [ procs], lib => []);



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