Commit ceb327f3 authored by Michael Natterer's avatar Michael Natterer 😴

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

The results are different here too, but tweakable like for cartoon.
parent 0e23d726
......@@ -28,7 +28,7 @@
#include "internal-procs.h"
/* 736 procedures registered total */
/* 737 procedures registered total */
void
internal_procs_init (GimpPDB *pdb)
......
......@@ -2657,6 +2657,55 @@ plug_in_papertile_invoker (GimpProcedure *procedure,
error ? *error : NULL);
}
static GimpValueArray *
plug_in_photocopy_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GimpValueArray *args,
GError **error)
{
gboolean success = TRUE;
GimpDrawable *drawable;
gdouble mask_radius;
gdouble sharpness;
gdouble pct_black;
gdouble pct_white;
drawable = gimp_value_get_drawable (gimp_value_array_index (args, 2), gimp);
mask_radius = g_value_get_double (gimp_value_array_index (args, 3));
sharpness = g_value_get_double (gimp_value_array_index (args, 4));
pct_black = g_value_get_double (gimp_value_array_index (args, 5));
pct_white = g_value_get_double (gimp_value_array_index (args, 6));
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:photocopy",
"mask-radius", mask_radius,
"sharpness", sharpness,
"black", pct_black,
"white", pct_white,
NULL);
gimp_drawable_apply_operation (drawable, progress,
C_("undo-type", "Photocopy"),
node);
g_object_unref (node);
}
else
success = FALSE;
}
return gimp_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static GimpValueArray *
plug_in_pixelize_invoker (GimpProcedure *procedure,
Gimp *gimp,
......@@ -6802,6 +6851,67 @@ register_plug_in_compat_procs (GimpPDB *pdb)
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* gimp-plug-in-photocopy
*/
procedure = gimp_procedure_new (plug_in_photocopy_invoker);
gimp_object_set_static_name (GIMP_OBJECT (procedure),
"plug-in-photocopy");
gimp_procedure_set_static_strings (procedure,
"plug-in-photocopy",
"Simulate color distortion produced by a copy machine",
"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 photocopied version of the image, with toner transferred based on the relative darkness of a particular region. This is achieved by darkening areas of the image which are measured to be darker than a neighborhood average and setting other pixels to white. 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 regions of white and much less detail for black areas everywhere including inside regions of color. Small values result in\n"
"less toner overall and more detail everywhere. Small values for the pct_black make the blend from the white regions to the black border lines smoother and the toner regions themselves thinner and less noticeable; larger values achieve the opposite effect.",
"Compatibility procedure. Please see 'gegl:photocopy' for credits.",
"Compatibility procedure. Please see 'gegl:photocopy' 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",
"Photocopy mask radius (radius of pixel neighborhood)",
3.0, 50.0, 3.0,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
g_param_spec_double ("sharpness",
"sharpness",
"Sharpness (detail level)",
0.0, 1.0, 0.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_procedure_add_argument (procedure,
g_param_spec_double ("pct-white",
"pct white",
"Percentage of non-darkened pixels left white",
0.0, 1.0, 0.0,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* gimp-plug-in-pixelize
*/
......
......@@ -2650,6 +2650,79 @@ CODE
);
}
sub plug_in_photocopy {
$blurb = 'Simulate color distortion produced by a copy machine';
$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 photocopied version of the image, with toner
transferred based on the relative darkness of a particular
region. This is achieved by darkening areas of the image which are
measured to be darker than a neighborhood average and setting other
pixels to white. 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
regions of white and much less detail for black areas everywhere
including inside regions of color. Small values result in less toner
overall and more detail everywhere. Small values for the pct_black
make the blend from the white regions to the black border lines
smoother and the toner regions themselves thinner and less noticeable;
larger values achieve the opposite effect.
HELP
&std_pdb_compat('gegl:photocopy');
$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 => '3.0 <= float <= 50.0',
desc => 'Photocopy mask radius (radius of pixel neighborhood)' },
{ name => 'sharpness', type => '0.0 <= float <= 1.0',
desc => 'Sharpness (detail level)' },
{ name => 'pct_black', type => '0.0 <= float <= 1.0',
desc => 'Percentage of darkened pixels to set to black' },
{ name => 'pct_white', type => '0.0 <= float <= 1.0',
desc => 'Percentage of non-darkened pixels left white' },
);
%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:photocopy",
"mask-radius", mask_radius,
"sharpness", sharpness,
"black", pct_black,
"white", pct_white,
NULL);
gimp_drawable_apply_operation (drawable, progress,
C_("undo-type", "Photocopy"),
node);
g_object_unref (node);
}
else
success = FALSE;
}
CODE
);
}
sub plug_in_pixelize {
$blurb = 'Simplify image into an array of solid-colored squares';
......@@ -4824,6 +4897,7 @@ CODE
plug_in_mosaic
plug_in_nova
plug_in_papertile
plug_in_photocopy
plug_in_pixelize
plug_in_pixelize2
plug_in_plasma
......
......@@ -144,8 +144,6 @@
/nl-filter.exe
/oilify
/oilify.exe
/photocopy
/photocopy.exe
/plugin-browser
/plugin-browser.exe
/procedure-browser
......
......@@ -117,7 +117,6 @@ max_rgb_libexecdir = $(gimpplugindir)/plug-ins/max-rgb
newsprint_libexecdir = $(gimpplugindir)/plug-ins/newsprint
nl_filter_libexecdir = $(gimpplugindir)/plug-ins/nl-filter
oilify_libexecdir = $(gimpplugindir)/plug-ins/oilify
photocopy_libexecdir = $(gimpplugindir)/plug-ins/photocopy
plugin_browser_libexecdir = $(gimpplugindir)/plug-ins/plugin-browser
procedure_browser_libexecdir = $(gimpplugindir)/plug-ins/procedure-browser
qbist_libexecdir = $(gimpplugindir)/plug-ins/qbist
......@@ -208,7 +207,6 @@ max_rgb_libexec_PROGRAMS = max-rgb
newsprint_libexec_PROGRAMS = newsprint
nl_filter_libexec_PROGRAMS = nl-filter
oilify_libexec_PROGRAMS = oilify
photocopy_libexec_PROGRAMS = photocopy
plugin_browser_libexec_PROGRAMS = plugin-browser
procedure_browser_libexec_PROGRAMS = procedure-browser
qbist_libexec_PROGRAMS = qbist
......@@ -1522,23 +1520,6 @@ oilify_LDADD = \
$(INTLLIBS) \
$(oilify_RC)
photocopy_SOURCES = \
photocopy.c
photocopy_LDADD = \
$(libgimpui) \
$(libgimpwidgets) \
$(libgimpmodule) \
$(libgimp) \
$(libgimpmath) \
$(libgimpconfig) \
$(libgimpcolor) \
$(libgimpbase) \
$(GTK_LIBS) \
$(RT_LIBS) \
$(INTLLIBS) \
$(photocopy_RC)
plugin_browser_SOURCES = \
plugin-browser.c
......
......@@ -69,7 +69,6 @@ max_rgb_RC = max-rgb.rc.o
newsprint_RC = newsprint.rc.o
nl_filter_RC = nl-filter.rc.o
oilify_RC = oilify.rc.o
photocopy_RC = photocopy.rc.o
plugin_browser_RC = plugin-browser.rc.o
procedure_browser_RC = procedure-browser.rc.o
qbist_RC = qbist.rc.o
......
This diff is collapsed.
......@@ -71,7 +71,6 @@
'newsprint' => { ui => 1 },
'nl-filter' => { ui => 1, gegl => 1 },
'oilify' => { ui => 1 },
'photocopy' => { ui => 1 },
'plugin-browser' => { ui => 1 },
'procedure-browser' => { ui => 1 },
'qbist' => { ui => 1, gegl => 1 },
......
......@@ -75,7 +75,6 @@ plug-ins/common/max-rgb.c
plug-ins/common/newsprint.c
plug-ins/common/nl-filter.c
plug-ins/common/oilify.c
plug-ins/common/photocopy.c
plug-ins/common/plugin-browser.c
plug-ins/common/procedure-browser.c
plug-ins/common/qbist.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