pdb, plug-ins: remove the blur-gauss plug-in and add compat procedures

Add a utility function to wrap PDB compat nodes in gimp:cast-format
ops, so we can use ops that are now implemented in linear RGB for
plug-in compat procedures, which are all supposed to work on gamma
corrected RGB.
This commit is contained in:
Michael Natterer
2014-05-04 22:48:56 +02:00
parent 84ce7f1a9a
commit ff59aebbe8
8 changed files with 773 additions and 1690 deletions

View File

@ -28,7 +28,7 @@
#include "internal-procs.h" #include "internal-procs.h"
/* 721 procedures registered total */ /* 726 procedures registered total */
void void
internal_procs_init (GimpPDB *pdb) internal_procs_init (GimpPDB *pdb)

View File

@ -42,6 +42,7 @@
#include "core/gimpparamspecs.h" #include "core/gimpparamspecs.h"
#include "core/gimppickable-auto-shrink.h" #include "core/gimppickable-auto-shrink.h"
#include "core/gimppickable.h" #include "core/gimppickable.h"
#include "gegl/gimp-babl.h"
#include "gegl/gimp-gegl-utils.h" #include "gegl/gimp-gegl-utils.h"
#include "gimppdb.h" #include "gimppdb.h"
@ -52,6 +53,95 @@
#include "gimp-intl.h" #include "gimp-intl.h"
static GeglNode *
wrap_in_gamma_cast (GeglNode *node,
GimpDrawable *drawable)
{
if (! gimp_drawable_get_linear (drawable))
{
const Babl *drawable_format;
const Babl *cast_format;
GeglNode *new_node;
GeglNode *input;
GeglNode *output;
GeglNode *cast_before;
GeglNode *cast_after;
drawable_format = gimp_drawable_get_format (drawable);
cast_format =
gimp_babl_format (gimp_babl_format_get_base_type (drawable_format),
gimp_babl_precision (gimp_babl_format_get_component_type (drawable_format),
TRUE),
babl_format_has_alpha (drawable_format));
new_node = gegl_node_new ();
gegl_node_add_child (new_node, node);
g_object_unref (node);
input = gegl_node_get_input_proxy (new_node, "input");
output = gegl_node_get_output_proxy (new_node, "output");
cast_before = gegl_node_new_child (new_node,
"operation", "gimp:cast-format",
"input-format", drawable_format,
"output-format", cast_format,
NULL);
cast_after = gegl_node_new_child (new_node,
"operation", "gimp:cast-format",
"input-format", cast_format,
"output-format", drawable_format,
NULL);
gegl_node_link_many (input,
cast_before,
node,
cast_after,
output,
NULL);
return new_node;
}
else
{
return node;
}
}
static gboolean
gaussian_blur (GimpDrawable *drawable,
gdouble horizontal,
gdouble vertical,
GimpProgress *progress,
GError **error)
{
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;
node = gegl_node_new_child (NULL,
"operation", "gegl:gaussian-blur",
"std-dev-x", horizontal * 0.32,
"std-dev-y", vertical * 0.32,
NULL);
node = wrap_in_gamma_cast (node, drawable);
gimp_drawable_apply_operation (drawable, progress,
C_("undo-type", "Gaussian Blur"),
node);
g_object_unref (node);
return TRUE;
}
return FALSE;
}
static GimpValueArray * static GimpValueArray *
plug_in_alienmap2_invoker (GimpProcedure *procedure, plug_in_alienmap2_invoker (GimpProcedure *procedure,
Gimp *gimp, Gimp *gimp,
@ -612,6 +702,146 @@ plug_in_cubism_invoker (GimpProcedure *procedure,
error ? *error : NULL); error ? *error : NULL);
} }
static GimpValueArray *
plug_in_gauss_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GimpValueArray *args,
GError **error)
{
gboolean success = TRUE;
GimpDrawable *drawable;
gdouble horizontal;
gdouble vertical;
drawable = gimp_value_get_drawable (gimp_value_array_index (args, 2), gimp);
horizontal = g_value_get_double (gimp_value_array_index (args, 3));
vertical = g_value_get_double (gimp_value_array_index (args, 4));
if (success)
{
success = gaussian_blur (drawable, horizontal, vertical, progress, error);
}
return gimp_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static GimpValueArray *
plug_in_gauss_iir_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GimpValueArray *args,
GError **error)
{
gboolean success = TRUE;
GimpDrawable *drawable;
gdouble radius;
gboolean horizontal;
gboolean vertical;
drawable = gimp_value_get_drawable (gimp_value_array_index (args, 2), gimp);
radius = g_value_get_double (gimp_value_array_index (args, 3));
horizontal = g_value_get_boolean (gimp_value_array_index (args, 4));
vertical = g_value_get_boolean (gimp_value_array_index (args, 5));
if (success)
{
success = gaussian_blur (drawable,
horizontal ? radius : 0.0,
vertical ? radius : 0.0,
progress, error);
}
return gimp_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static GimpValueArray *
plug_in_gauss_iir2_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GimpValueArray *args,
GError **error)
{
gboolean success = TRUE;
GimpDrawable *drawable;
gdouble horizontal;
gdouble vertical;
drawable = gimp_value_get_drawable (gimp_value_array_index (args, 2), gimp);
horizontal = g_value_get_double (gimp_value_array_index (args, 3));
vertical = g_value_get_double (gimp_value_array_index (args, 4));
if (success)
{
success = gaussian_blur (drawable, horizontal, vertical, progress, error);
}
return gimp_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static GimpValueArray *
plug_in_gauss_rle_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GimpValueArray *args,
GError **error)
{
gboolean success = TRUE;
GimpDrawable *drawable;
gdouble radius;
gboolean horizontal;
gboolean vertical;
drawable = gimp_value_get_drawable (gimp_value_array_index (args, 2), gimp);
radius = g_value_get_double (gimp_value_array_index (args, 3));
horizontal = g_value_get_boolean (gimp_value_array_index (args, 4));
vertical = g_value_get_boolean (gimp_value_array_index (args, 5));
if (success)
{
success = gaussian_blur (drawable,
horizontal ? radius : 0.0,
vertical ? radius : 0.0,
progress, error);
}
return gimp_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static GimpValueArray *
plug_in_gauss_rle2_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GimpValueArray *args,
GError **error)
{
gboolean success = TRUE;
GimpDrawable *drawable;
gdouble horizontal;
gdouble vertical;
drawable = gimp_value_get_drawable (gimp_value_array_index (args, 2), gimp);
horizontal = g_value_get_double (gimp_value_array_index (args, 3));
vertical = g_value_get_double (gimp_value_array_index (args, 4));
if (success)
{
success = gaussian_blur (drawable, horizontal, vertical, progress, error);
}
return gimp_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static GimpValueArray * static GimpValueArray *
plug_in_hsv_noise_invoker (GimpProcedure *procedure, plug_in_hsv_noise_invoker (GimpProcedure *procedure,
Gimp *gimp, Gimp *gimp,
@ -2371,6 +2601,264 @@ register_plug_in_compat_procs (GimpPDB *pdb)
gimp_pdb_register_procedure (pdb, procedure); gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure); g_object_unref (procedure);
/*
* gimp-plug-in-gauss
*/
procedure = gimp_procedure_new (plug_in_gauss_invoker);
gimp_object_set_static_name (GIMP_OBJECT (procedure),
"plug-in-gauss");
gimp_procedure_set_static_strings (procedure,
"plug-in-gauss",
"Simplest, most commonly used way of blurring",
"Applies a gaussian blur to the drawable, with specified radius of affect. The standard deviation of the normal distribution used to modify pixel values is calculated based on the supplied radius. Horizontal and vertical blurring can be independently invoked by specifying only one to run. The 'method' parameter is ignored.",
"Compatibility procedure. Please see 'gegl:gaussian-blur' for credits.",
"Compatibility procedure. Please see 'gegl:gaussian-blur' for credits.",
"2014",
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,
g_param_spec_double ("horizontal",
"horizontal",
"Horizontal radius of gaussian blur (in pixels",
0.0, 500.0, 0.0,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
g_param_spec_double ("vertical",
"vertical",
"Vertical radius of gaussian blur (in pixels",
0.0, 500.0, 0.0,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
gimp_param_spec_int32 ("method",
"method",
"Blur method { IIR (0), RLE (1) }",
0, 1, 0,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* gimp-plug-in-gauss-iir
*/
procedure = gimp_procedure_new (plug_in_gauss_iir_invoker);
gimp_object_set_static_name (GIMP_OBJECT (procedure),
"plug-in-gauss-iir");
gimp_procedure_set_static_strings (procedure,
"plug-in-gauss-iir",
"Apply a gaussian blur",
"Applies a gaussian blur to the drawable, with specified radius of affect. The standard deviation of the normal distribution used to modify pixel values is calculated based on the supplied radius. Horizontal and vertical blurring can be independently invoked by specifying only one to run.",
"Compatibility procedure. Please see 'gegl:gaussian-blur' for credits.",
"Compatibility procedure. Please see 'gegl:gaussian-blur' for credits.",
"2014",
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,
g_param_spec_double ("radius",
"radius",
"Radius of gaussian blur (in pixels",
0.0, 500.0, 0.0,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
g_param_spec_boolean ("horizontal",
"horizontal",
"Blur in horizontal direction",
FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
g_param_spec_boolean ("vertical",
"vertical",
"Blur in vertical direction",
FALSE,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* gimp-plug-in-gauss-iir2
*/
procedure = gimp_procedure_new (plug_in_gauss_iir2_invoker);
gimp_object_set_static_name (GIMP_OBJECT (procedure),
"plug-in-gauss-iir2");
gimp_procedure_set_static_strings (procedure,
"plug-in-gauss-iir2",
"Apply a gaussian blur",
"Applies a gaussian blur to the drawable, with specified radius of affect. The standard deviation of the normal distribution used to modify pixel values is calculated based on the supplied radius. Horizontal and vertical blurring can be independently invoked by specifying only one to run.",
"Compatibility procedure. Please see 'gegl:gaussian-blur' for credits.",
"Compatibility procedure. Please see 'gegl:gaussian-blur' for credits.",
"2014",
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,
g_param_spec_double ("horizontal",
"horizontal",
"Horizontal radius of gaussian blur (in pixels",
0.0, 500.0, 0.0,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
g_param_spec_double ("vertical",
"vertical",
"Vertical radius of gaussian blur (in pixels",
0.0, 500.0, 0.0,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* gimp-plug-in-gauss-rle
*/
procedure = gimp_procedure_new (plug_in_gauss_rle_invoker);
gimp_object_set_static_name (GIMP_OBJECT (procedure),
"plug-in-gauss-rle");
gimp_procedure_set_static_strings (procedure,
"plug-in-gauss-rle",
"Apply a gaussian blur",
"Applies a gaussian blur to the drawable, with specified radius of affect. The standard deviation of the normal distribution used to modify pixel values is calculated based on the supplied radius. Horizontal and vertical blurring can be independently invoked by specifying only one to run.",
"Compatibility procedure. Please see 'gegl:gaussian-blur' for credits.",
"Compatibility procedure. Please see 'gegl:gaussian-blur' for credits.",
"2014",
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,
g_param_spec_double ("radius",
"radius",
"Radius of gaussian blur (in pixels",
0.0, 500.0, 0.0,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
g_param_spec_boolean ("horizontal",
"horizontal",
"Blur in horizontal direction",
FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
g_param_spec_boolean ("vertical",
"vertical",
"Blur in vertical direction",
FALSE,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* gimp-plug-in-gauss-rle2
*/
procedure = gimp_procedure_new (plug_in_gauss_rle2_invoker);
gimp_object_set_static_name (GIMP_OBJECT (procedure),
"plug-in-gauss-rle2");
gimp_procedure_set_static_strings (procedure,
"plug-in-gauss-rle2",
"Apply a gaussian blur",
"Applies a gaussian blur to the drawable, with specified radius of affect. The standard deviation of the normal distribution used to modify pixel values is calculated based on the supplied radius. Horizontal and vertical blurring can be independently invoked by specifying only one to run.",
"Compatibility procedure. Please see 'gegl:gaussian-blur' for credits.",
"Compatibility procedure. Please see 'gegl:gaussian-blur' for credits.",
"2014",
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,
g_param_spec_double ("horizontal",
"horizontal",
"Horizontal radius of gaussian blur (in pixels",
0.0, 500.0, 0.0,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
g_param_spec_double ("vertical",
"vertical",
"Vertical radius of gaussian blur (in pixels",
0.0, 500.0, 0.0,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/* /*
* gimp-plug-in-hsv-noise * gimp-plug-in-hsv-noise
*/ */

View File

@ -12,8 +12,6 @@
/blinds.exe /blinds.exe
/blur /blur
/blur.exe /blur.exe
/blur-gauss
/blur-gauss.exe
/blur-gauss-selective /blur-gauss-selective
/blur-gauss-selective.exe /blur-gauss-selective.exe
/border-average /border-average

View File

@ -49,7 +49,6 @@ libexec_PROGRAMS = \
animation-play \ animation-play \
blinds \ blinds \
blur \ blur \
blur-gauss \
blur-gauss-selective \ blur-gauss-selective \
border-average \ border-average \
bump-map \ bump-map \
@ -276,23 +275,6 @@ blur_LDADD = \
$(INTLLIBS) \ $(INTLLIBS) \
$(blur_RC) $(blur_RC)
blur_gauss_SOURCES = \
blur-gauss.c
blur_gauss_LDADD = \
$(libgimpui) \
$(libgimpwidgets) \
$(libgimpmodule) \
$(libgimp) \
$(libgimpmath) \
$(libgimpconfig) \
$(libgimpcolor) \
$(libgimpbase) \
$(GTK_LIBS) \
$(RT_LIBS) \
$(INTLLIBS) \
$(blur_gauss_RC)
blur_gauss_selective_CFLAGS = $(MMX_EXTRA_CFLAGS) blur_gauss_selective_CFLAGS = $(MMX_EXTRA_CFLAGS)
blur_gauss_selective_SOURCES = \ blur_gauss_selective_SOURCES = \

File diff suppressed because it is too large Load Diff

View File

@ -3,7 +3,6 @@ animation_optimize_RC = animation-optimize.rc.o
animation_play_RC = animation-play.rc.o animation_play_RC = animation-play.rc.o
blinds_RC = blinds.rc.o blinds_RC = blinds.rc.o
blur_RC = blur.rc.o blur_RC = blur.rc.o
blur_gauss_RC = blur-gauss.rc.o
blur_gauss_selective_RC = blur-gauss-selective.rc.o blur_gauss_selective_RC = blur-gauss-selective.rc.o
border_average_RC = border-average.rc.o border_average_RC = border-average.rc.o
bump_map_RC = bump-map.rc.o bump_map_RC = bump-map.rc.o

View File

@ -4,7 +4,6 @@
'animation-play' => { ui => 1, gegl => 1 }, 'animation-play' => { ui => 1, gegl => 1 },
'blinds' => { ui => 1 }, 'blinds' => { ui => 1 },
'blur' => {}, 'blur' => {},
'blur-gauss' => { ui => 1 },
'blur-gauss-selective' => { ui => 1, cflags => 'MMX_EXTRA_CFLAGS' }, 'blur-gauss-selective' => { ui => 1, cflags => 'MMX_EXTRA_CFLAGS' },
'border-average' => { ui => 1, gegl => 1 }, 'border-average' => { ui => 1, gegl => 1 },
'bump-map' => { ui => 1 }, 'bump-map' => { ui => 1 },

View File

@ -651,6 +651,194 @@ CODE
); );
} }
sub plug_in_gauss {
$blurb = 'Simplest, most commonly used way of blurring';
$help = <<'HELP';
Applies a gaussian blur to the drawable, with specified radius of affect.
The standard deviation of the normal distribution used to modify pixel
values is calculated based on the supplied radius.
Horizontal and vertical blurring can be independently invoked by specifying
only one to run. The 'method' parameter is ignored.
HELP
&std_pdb_compat('gegl:gaussian-blur');
$date = '2014';
@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 => 'horizontal', type => '0.0 <= float <= 500.0',
desc => 'Horizontal radius of gaussian blur (in pixels' },
{ name => 'vertical', type => '0.0 <= float <= 500.0',
desc => 'Vertical radius of gaussian blur (in pixels' },
{ name => 'method', type => '0 <= int32 <= 1', dead => 1,
desc => 'Blur method { IIR (0), RLE (1) }' }
);
%invoke = (
code => <<'CODE'
{
success = gaussian_blur (drawable, horizontal, vertical, progress, error);
}
CODE
);
}
sub plug_in_gauss_iir {
$blurb = 'Apply a gaussian blur';
$help = <<'HELP';
Applies a gaussian blur to the drawable, with specified radius of affect.
The standard deviation of the normal distribution used to modify pixel
values is calculated based on the supplied radius. Horizontal and vertical
blurring can be independently invoked by specifying only one to run.
HELP
&std_pdb_compat('gegl:gaussian-blur');
$date = '2014';
@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 => '0.0 <= float <= 500.0',
desc => 'Radius of gaussian blur (in pixels' },
{ name => 'horizontal', type => 'boolean',
desc => 'Blur in horizontal direction' },
{ name => 'vertical', type => 'boolean',
desc => 'Blur in vertical direction' }
);
%invoke = (
code => <<'CODE'
{
success = gaussian_blur (drawable,
horizontal ? radius : 0.0,
vertical ? radius : 0.0,
progress, error);
}
CODE
);
}
sub plug_in_gauss_iir2 {
$blurb = 'Apply a gaussian blur';
$help = <<'HELP';
Applies a gaussian blur to the drawable, with specified radius of affect.
The standard deviation of the normal distribution used to modify pixel
values is calculated based on the supplied radius. Horizontal and vertical
blurring can be independently invoked by specifying only one to run.
HELP
&std_pdb_compat('gegl:gaussian-blur');
$date = '2014';
@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 => 'horizontal', type => '0.0 <= float <= 500.0',
desc => 'Horizontal radius of gaussian blur (in pixels' },
{ name => 'vertical', type => '0.0 <= float <= 500.0',
desc => 'Vertical radius of gaussian blur (in pixels' },
);
%invoke = (
code => <<'CODE'
{
success = gaussian_blur (drawable, horizontal, vertical, progress, error);
}
CODE
);
}
sub plug_in_gauss_rle {
$blurb = 'Apply a gaussian blur';
$help = <<'HELP';
Applies a gaussian blur to the drawable, with specified radius of affect.
The standard deviation of the normal distribution used to modify pixel
values is calculated based on the supplied radius. Horizontal and vertical
blurring can be independently invoked by specifying only one to run.
HELP
&std_pdb_compat('gegl:gaussian-blur');
$date = '2014';
@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 => '0.0 <= float <= 500.0',
desc => 'Radius of gaussian blur (in pixels' },
{ name => 'horizontal', type => 'boolean',
desc => 'Blur in horizontal direction' },
{ name => 'vertical', type => 'boolean',
desc => 'Blur in vertical direction' }
);
%invoke = (
code => <<'CODE'
{
success = gaussian_blur (drawable,
horizontal ? radius : 0.0,
vertical ? radius : 0.0,
progress, error);
}
CODE
);
}
sub plug_in_gauss_rle2 {
$blurb = 'Apply a gaussian blur';
$help = <<'HELP';
Applies a gaussian blur to the drawable, with specified radius of affect.
The standard deviation of the normal distribution used to modify pixel
values is calculated based on the supplied radius. Horizontal and vertical
blurring can be independently invoked by specifying only one to run.
HELP
&std_pdb_compat('gegl:gaussian-blur');
$date = '2014';
@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 => 'horizontal', type => '0.0 <= float <= 500.0',
desc => 'Horizontal radius of gaussian blur (in pixels' },
{ name => 'vertical', type => '0.0 <= float <= 500.0',
desc => 'Vertical radius of gaussian blur (in pixels' },
);
%invoke = (
code => <<'CODE'
{
success = gaussian_blur (drawable, horizontal, vertical, progress, error);
}
CODE
);
}
sub plug_in_hsv_noise { sub plug_in_hsv_noise {
$blurb = 'Randomize hue, saturation and value independently'; $blurb = 'Randomize hue, saturation and value independently';
@ -1997,9 +2185,100 @@ CODE
); );
} }
$extra{app}->{code} = <<'CODE';
static GeglNode *
wrap_in_gamma_cast (GeglNode *node,
GimpDrawable *drawable)
{
if (! gimp_drawable_get_linear (drawable))
{
const Babl *drawable_format;
const Babl *cast_format;
GeglNode *new_node;
GeglNode *input;
GeglNode *output;
GeglNode *cast_before;
GeglNode *cast_after;
drawable_format = gimp_drawable_get_format (drawable);
cast_format =
gimp_babl_format (gimp_babl_format_get_base_type (drawable_format),
gimp_babl_precision (gimp_babl_format_get_component_type (drawable_format),
TRUE),
babl_format_has_alpha (drawable_format));
new_node = gegl_node_new ();
gegl_node_add_child (new_node, node);
g_object_unref (node);
input = gegl_node_get_input_proxy (new_node, "input");
output = gegl_node_get_output_proxy (new_node, "output");
cast_before = gegl_node_new_child (new_node,
"operation", "gimp:cast-format",
"input-format", drawable_format,
"output-format", cast_format,
NULL);
cast_after = gegl_node_new_child (new_node,
"operation", "gimp:cast-format",
"input-format", cast_format,
"output-format", drawable_format,
NULL);
gegl_node_link_many (input,
cast_before,
node,
cast_after,
output,
NULL);
return new_node;
}
else
{
return node;
}
}
static gboolean
gaussian_blur (GimpDrawable *drawable,
gdouble horizontal,
gdouble vertical,
GimpProgress *progress,
GError **error)
{
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;
node = gegl_node_new_child (NULL,
"operation", "gegl:gaussian-blur",
"std-dev-x", horizontal * 0.32,
"std-dev-y", vertical * 0.32,
NULL);
node = wrap_in_gamma_cast (node, drawable);
gimp_drawable_apply_operation (drawable, progress,
C_("undo-type", "Gaussian Blur"),
node);
g_object_unref (node);
return TRUE;
}
return FALSE;
}
CODE
@headers = qw("libgimpbase/gimpbase.h" @headers = qw("libgimpbase/gimpbase.h"
"libgimpmath/gimpmath.h" "libgimpmath/gimpmath.h"
"gegl/gimp-babl.h"
"gegl/gimp-gegl-utils.h" "gegl/gimp-gegl-utils.h"
"core/gimpcontext.h" "core/gimpcontext.h"
"core/gimpdrawable.h" "core/gimpdrawable.h"
@ -2022,6 +2301,11 @@ CODE
plug_in_colors_channel_mixer plug_in_colors_channel_mixer
plug_in_colortoalpha plug_in_colortoalpha
plug_in_cubism plug_in_cubism
plug_in_gauss
plug_in_gauss_iir
plug_in_gauss_iir2
plug_in_gauss_rle
plug_in_gauss_rle2
plug_in_hsv_noise plug_in_hsv_noise
plug_in_laplace plug_in_laplace
plug_in_lens_distortion plug_in_lens_distortion