[gimp/gimp-2-10] pdb: add a PDB compat procedure for median-blur
- From: Jehan <jehanp src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/gimp-2-10] pdb: add a PDB compat procedure for median-blur
- Date: Sun, 25 Apr 2021 12:51:06 +0000 (UTC)
commit eb9eec4acbe211fb98b5aa8d4235bdba60272c55
Author: Ian Martins <ianxm jhu edu>
Date: Fri Feb 5 07:45:01 2021 -0500
pdb: add a PDB compat procedure for median-blur
app/pdb/internal-procs.c | 2 +-
app/pdb/plug-in-compat-cmds.c | 91 +++++++++++++++++++++++++++++++++++++++++++
pdb/groups/plug_in_compat.pdb | 51 ++++++++++++++++++++++++
3 files changed, 143 insertions(+), 1 deletion(-)
---
diff --git a/app/pdb/internal-procs.c b/app/pdb/internal-procs.c
index 6363937669..3f41bb7e66 100644
--- a/app/pdb/internal-procs.c
+++ b/app/pdb/internal-procs.c
@@ -28,7 +28,7 @@
#include "internal-procs.h"
-/* 849 procedures registered total */
+/* 850 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 93766ce372..d9d0bf6b58 100644
--- a/app/pdb/plug-in-compat-cmds.c
+++ b/app/pdb/plug-in-compat-cmds.c
@@ -2714,6 +2714,49 @@ plug_in_mblur_inward_invoker (GimpProcedure *procedure,
error ? *error : NULL);
}
+static GimpValueArray *
+plug_in_median_blur_invoker (GimpProcedure *procedure,
+ Gimp *gimp,
+ GimpContext *context,
+ GimpProgress *progress,
+ const GimpValueArray *args,
+ GError **error)
+{
+ gboolean success = TRUE;
+ GimpDrawable *drawable;
+ gint32 radius;
+ gdouble percentile;
+
+ drawable = gimp_value_get_drawable (gimp_value_array_index (args, 2), gimp);
+ radius = g_value_get_int (gimp_value_array_index (args, 3));
+ percentile = g_value_get_double (gimp_value_array_index (args, 4));
+
+ 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:median-blur",
+ "radius", radius,
+ "percentile", percentile,
+ NULL);
+
+ gimp_drawable_apply_operation (drawable, progress,
+ C_("undo-type", "Median Blur"),
+ node);
+ g_object_unref (node);
+ }
+ else
+ success = FALSE;
+ }
+
+ return gimp_procedure_get_return_values (procedure, success,
+ error ? *error : NULL);
+}
+
static GimpValueArray *
plug_in_mosaic_invoker (GimpProcedure *procedure,
Gimp *gimp,
@@ -7257,6 +7300,54 @@ register_plug_in_compat_procs (GimpPDB *pdb)
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
+ /*
+ * gimp-plug-in-median-blur
+ */
+ procedure = gimp_procedure_new (plug_in_median_blur_invoker);
+ gimp_object_set_static_name (GIMP_OBJECT (procedure),
+ "plug-in-median-blur");
+ gimp_procedure_set_static_strings (procedure,
+ "plug-in-median-blur",
+ "Blur using the median color near each pixel",
+ "Blur resulting from computing the median color in the neighborhood of
each pixel",
+ "Compatibility procedure. Please see 'gegl:median-blur' for credits.",
+ "Compatibility procedure. Please see 'gegl:median-blur' for credits.",
+ "2021",
+ 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 ("radius",
+ "radius",
+ "Neighborhood radius, a negative value will calculate
with inverted percentiles",
+ -400, 400, -400,
+ GIMP_PARAM_READWRITE));
+ gimp_procedure_add_argument (procedure,
+ g_param_spec_double ("percentile",
+ "percentile",
+ "Neighborhood color percentile",
+ 0, 100, 0,
+ GIMP_PARAM_READWRITE));
+ gimp_pdb_register_procedure (pdb, procedure);
+ g_object_unref (procedure);
+
/*
* gimp-plug-in-mosaic
*/
diff --git a/pdb/groups/plug_in_compat.pdb b/pdb/groups/plug_in_compat.pdb
index 184d80df2b..ed6cb7484a 100644
--- a/pdb/groups/plug_in_compat.pdb
+++ b/pdb/groups/plug_in_compat.pdb
@@ -2610,6 +2610,56 @@ CODE
);
}
+sub plug_in_median_blur {
+ $blurb = 'Blur using the median color near each pixel';
+
+ $help = <<'HELP';
+Blur resulting from computing the median color in the
+neighborhood of each pixel
+HELP
+
+ &std_pdb_compat('gegl:median-blur');
+ $date = '2021';
+
+ @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 => 'radius', type => '-400 <= int32 <= 400',
+ desc => 'Neighborhood radius, a negative value will calculate with inverted percentiles' },
+ { name => 'percentile', type => '0 <= float <= 100',
+ desc => 'Neighborhood color percentile' }
+ );
+
+ %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:median-blur",
+ "radius", radius,
+ "percentile", percentile,
+ NULL);
+
+ gimp_drawable_apply_operation (drawable, progress,
+ C_("undo-type", "Median Blur"),
+ node);
+ g_object_unref (node);
+ }
+ else
+ success = FALSE;
+}
+CODE
+ );
+}
+
sub plug_in_mosaic {
$blurb = 'Convert the image into irregular tiles';
@@ -5454,6 +5504,7 @@ CODE
plug_in_maze
plug_in_mblur
plug_in_mblur_inward
+ plug_in_median_blur
plug_in_mosaic
plug_in_neon
plug_in_newsprint
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]