Commit 529ee9ef authored by Michael Natterer's avatar Michael Natterer 😴

plug-ins, pdb: remove the cartoon plug-in and add a PDB compat procedure

The result of the GEGL op is a bitt different but so what, this is an
artistic effect and the result can be tweaked with parameters.
parent 0188853b
......@@ -28,7 +28,7 @@
#include "internal-procs.h"
/* 735 procedures registered total */
/* 736 procedures registered total */
void
internal_procs_init (GimpPDB *pdb)
......
......@@ -870,6 +870,49 @@ plug_in_c_astretch_invoker (GimpProcedure *procedure,
error ? *error : NULL);
}
static GimpValueArray *
plug_in_cartoon_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GimpValueArray *args,
GError **error)
{
gboolean success = TRUE;
GimpDrawable *drawable;
gdouble mask_radius;
gdouble pct_black;
drawable = gimp_value_get_drawable (gimp_value_array_index (args, 2), gimp);
mask_radius = g_value_get_double (gimp_value_array_index (args, 3));
pct_black = 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:cartoon",
"mask-radius", mask_radius,
"pct-black", pct_black,
NULL);
gimp_drawable_apply_operation (drawable, progress,
C_("undo-type", "Cartoon"),
node);
g_object_unref (node);
}
else
success = FALSE;
}
return gimp_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static GimpValueArray *
plug_in_colors_channel_mixer_invoker (GimpProcedure *procedure,
Gimp *gimp,
......@@ -4783,6 +4826,55 @@ register_plug_in_compat_procs (GimpPDB *pdb)
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* gimp-plug-in-cartoon
*/
procedure = gimp_procedure_new (plug_in_cartoon_invoker);
gimp_object_set_static_name (GIMP_OBJECT (procedure),
"plug-in-cartoon");
gimp_procedure_set_static_strings (procedure,
"plug-in-cartoon",
"Simulate a cartoon by enhancing edges",
"Propagates dark values in an image based on each pixel's relative darkness to a neighboring average. The idea behind this filter is to give the look of a black felt pen drawing subsequently shaded with color. This is achieved by darkening areas of the image which are measured to be darker than a neighborhood average. In this way, sufficiently large shifts in intensity are darkened to black. The rate at which they are darkened to black is determined by the second pct_black parameter. The mask_radius parameter controls the size of the pixel neighborhood over which the average intensity is computed and then compared to each pixel in the neighborhood to decide whether or not to darken it to black. Large values for mask_radius result in very thick black areas bordering the shaded regions of color and much less detail for black areas everywhere including inside regions of color. Small values result in more subtle pen strokes and detail everywhere. Small values for the pct_black make the\n"
"blend from the color regions to the black border lines smoother and the lines themselves thinner and less noticeable; larger values achieve the opposite effect.",
"Compatibility procedure. Please see 'gegl:cartoon' for credits.",
"Compatibility procedure. Please see 'gegl:cartoon' for credits.",
"2019",
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 ("mask-radius",
"mask radius",
"Cartoon mask radius (radius of pixel neighborhood)",
1.0, 50.0, 1.0,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
g_param_spec_double ("pct-black",
"pct black",
"Percentage of darkened pixels to set to black",
0.0, 1.0, 0.0,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* gimp-plug-in-colors-channel-mixer
*/
......
......@@ -608,6 +608,72 @@ CODE
);
}
sub plug_in_cartoon {
$blurb = 'Simulate a cartoon by enhancing edges';
$help = <<'HELP';
Propagates dark values in an image based on each pixel's relative
darkness to a neighboring average. The idea behind this filter is to
give the look of a black felt pen drawing subsequently shaded with
color. This is achieved by darkening areas of the image which are
measured to be darker than a neighborhood average. In this way,
sufficiently large shifts in intensity are darkened to black. The rate
at which they are darkened to black is determined by the second
pct_black parameter. The mask_radius parameter controls the size of
the pixel neighborhood over which the average intensity is computed
and then compared to each pixel in the neighborhood to decide whether
or not to darken it to black. Large values for mask_radius result in
very thick black areas bordering the shaded regions of color and much
less detail for black areas everywhere including inside regions of
color. Small values result in more subtle pen strokes and detail
everywhere. Small values for the pct_black make the blend from the
color regions to the black border lines smoother and the lines
themselves thinner and less noticeable; larger values achieve the
opposite effect.
HELP
&std_pdb_compat('gegl:cartoon');
$date = '2019';
@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 => 'mask_radius', type => '1.0 <= float <= 50.0',
desc => 'Cartoon mask radius (radius of pixel neighborhood)' },
{ name => 'pct_black', type => '0.0 <= float <= 1.0',
desc => 'Percentage of darkened pixels to set to black' },
);
%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:cartoon",
"mask-radius", mask_radius,
"pct-black", pct_black,
NULL);
gimp_drawable_apply_operation (drawable, progress,
C_("undo-type", "Cartoon"),
node);
g_object_unref (node);
}
else
success = FALSE;
}
CODE
);
}
sub plug_in_colors_channel_mixer {
$blurb = 'Alter colors by mixing RGB Channels';
......@@ -4727,6 +4793,7 @@ CODE
plug_in_bump_map
plug_in_bump_map_tiled
plug_in_c_astretch
plug_in_cartoon
plug_in_colors_channel_mixer
plug_in_colortoalpha
plug_in_convmatrix
......
......@@ -14,8 +14,6 @@
/border-average.exe
/busy-dialog
/busy-dialog.exe
/cartoon
/cartoon.exe
/checkerboard
/checkerboard.exe
/cml-explorer
......
......@@ -52,7 +52,6 @@ blinds_libexecdir = $(gimpplugindir)/plug-ins/blinds
blur_libexecdir = $(gimpplugindir)/plug-ins/blur
border_average_libexecdir = $(gimpplugindir)/plug-ins/border-average
busy_dialog_libexecdir = $(gimpplugindir)/plug-ins/busy-dialog
cartoon_libexecdir = $(gimpplugindir)/plug-ins/cartoon
checkerboard_libexecdir = $(gimpplugindir)/plug-ins/checkerboard
cml_explorer_libexecdir = $(gimpplugindir)/plug-ins/cml-explorer
color_cube_analyze_libexecdir = $(gimpplugindir)/plug-ins/color-cube-analyze
......@@ -144,7 +143,6 @@ blinds_libexec_PROGRAMS = blinds
blur_libexec_PROGRAMS = blur
border_average_libexec_PROGRAMS = border-average
busy_dialog_libexec_PROGRAMS = busy-dialog
cartoon_libexec_PROGRAMS = cartoon
checkerboard_libexec_PROGRAMS = checkerboard
cml_explorer_libexec_PROGRAMS = cml-explorer
color_cube_analyze_libexec_PROGRAMS = color-cube-analyze
......@@ -356,23 +354,6 @@ busy_dialog_LDADD = \
$(INTLLIBS) \
$(busy_dialog_RC)
cartoon_SOURCES = \
cartoon.c
cartoon_LDADD = \
$(libgimpui) \
$(libgimpwidgets) \
$(libgimpmodule) \
$(libgimp) \
$(libgimpmath) \
$(libgimpconfig) \
$(libgimpcolor) \
$(libgimpbase) \
$(GTK_LIBS) \
$(RT_LIBS) \
$(INTLLIBS) \
$(cartoon_RC)
checkerboard_SOURCES = \
checkerboard.c
......
This diff is collapsed.
......@@ -4,7 +4,6 @@ blinds_RC = blinds.rc.o
blur_RC = blur.rc.o
border_average_RC = border-average.rc.o
busy_dialog_RC = busy-dialog.rc.o
cartoon_RC = cartoon.rc.o
checkerboard_RC = checkerboard.rc.o
cml_explorer_RC = cml-explorer.rc.o
color_cube_analyze_RC = color-cube-analyze.rc.o
......
......@@ -6,7 +6,6 @@
'blur' => {},
'border-average' => { ui => 1, gegl => 1 },
'busy-dialog' => { ui => 1, gegl => 1 },
'cartoon' => { ui => 1 },
'checkerboard' => { ui => 1, gegl => 1 },
'cml-explorer' => { ui => 1 },
'color-cube-analyze' => { ui => 1 },
......
......@@ -10,7 +10,6 @@ plug-ins/common/blinds.c
plug-ins/common/blur.c
plug-ins/common/border-average.c
plug-ins/common/busy-dialog.c
plug-ins/common/cartoon.c
plug-ins/common/checkerboard.c
plug-ins/common/cml-explorer.c
plug-ins/common/color-cube-analyze.c
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment