mirror of https://github.com/GNOME/gimp.git
pdb: add a PDB compat procedure for median-blur
(cherry picked from commit eb9eec4acb
)
Reviewer note: with re-generated C files for the updated PDB in the main
branch.
This commit is contained in:
parent
b7a06795d6
commit
c97cf30e6e
|
@ -28,7 +28,7 @@
|
|||
#include "internal-procs.h"
|
||||
|
||||
|
||||
/* 757 procedures registered total */
|
||||
/* 758 procedures registered total */
|
||||
|
||||
void
|
||||
internal_procs_init (GimpPDB *pdb)
|
||||
|
|
|
@ -2614,6 +2614,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;
|
||||
gint radius;
|
||||
gdouble percentile;
|
||||
|
||||
drawable = g_value_get_object (gimp_value_array_index (args, 2));
|
||||
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,
|
||||
|
@ -7246,6 +7289,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_help (procedure,
|
||||
"Blur using the median color near each pixel",
|
||||
"Blur resulting from computing the median color in the neighborhood of each pixel",
|
||||
NULL);
|
||||
gimp_procedure_set_static_attribution (procedure,
|
||||
"Compatibility procedure. Please see 'gegl:median-blur' for credits.",
|
||||
"Compatibility procedure. Please see 'gegl:median-blur' for credits.",
|
||||
"2021");
|
||||
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 ("image",
|
||||
"image",
|
||||
"Input image (unused)",
|
||||
FALSE,
|
||||
GIMP_PARAM_READWRITE));
|
||||
gimp_procedure_add_argument (procedure,
|
||||
gimp_param_spec_drawable ("drawable",
|
||||
"drawable",
|
||||
"Input drawable",
|
||||
FALSE,
|
||||
GIMP_PARAM_READWRITE));
|
||||
gimp_procedure_add_argument (procedure,
|
||||
g_param_spec_int ("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
|
||||
*/
|
||||
|
|
|
@ -2525,6 +2525,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';
|
||||
|
||||
|
@ -5503,6 +5553,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
|
||||
|
|
Loading…
Reference in New Issue