[gimp] plug-ins, pdb: remove the photocopy plug-in and add a PDB compat procedure
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] plug-ins, pdb: remove the photocopy plug-in and add a PDB compat procedure
- Date: Thu, 11 Jul 2019 10:35:07 +0000 (UTC)
commit ceb327f357708673897b71dde5f928e73d931ffc
Author: Michael Natterer <mitch gimp org>
Date: Thu Jul 11 12:33:56 2019 +0200
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.
app/pdb/internal-procs.c | 2 +-
app/pdb/plug-in-compat-cmds.c | 110 +++++
pdb/groups/plug_in_compat.pdb | 74 ++++
plug-ins/common/.gitignore | 2 -
plug-ins/common/Makefile.am | 19 -
plug-ins/common/gimprc.common | 1 -
plug-ins/common/photocopy.c | 945 -----------------------------------------
plug-ins/common/plugin-defs.pl | 1 -
po-plug-ins/POTFILES.in | 1 -
9 files changed, 185 insertions(+), 970 deletions(-)
---
diff --git a/app/pdb/internal-procs.c b/app/pdb/internal-procs.c
index 6d307a4147..61f0280e70 100644
--- a/app/pdb/internal-procs.c
+++ b/app/pdb/internal-procs.c
@@ -28,7 +28,7 @@
#include "internal-procs.h"
-/* 736 procedures registered total */
+/* 737 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 17a8d7b165..5dba70ef81 100644
--- a/app/pdb/plug-in-compat-cmds.c
+++ b/app/pdb/plug-in-compat-cmds.c
@@ -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
*/
diff --git a/pdb/groups/plug_in_compat.pdb b/pdb/groups/plug_in_compat.pdb
index 0f63f8e424..60cd7c7669 100644
--- a/pdb/groups/plug_in_compat.pdb
+++ b/pdb/groups/plug_in_compat.pdb
@@ -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
diff --git a/plug-ins/common/.gitignore b/plug-ins/common/.gitignore
index c712fc03d3..d0465cde32 100644
--- a/plug-ins/common/.gitignore
+++ b/plug-ins/common/.gitignore
@@ -144,8 +144,6 @@
/nl-filter.exe
/oilify
/oilify.exe
-/photocopy
-/photocopy.exe
/plugin-browser
/plugin-browser.exe
/procedure-browser
diff --git a/plug-ins/common/Makefile.am b/plug-ins/common/Makefile.am
index 590c8329cb..5fa39bee55 100644
--- a/plug-ins/common/Makefile.am
+++ b/plug-ins/common/Makefile.am
@@ -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
diff --git a/plug-ins/common/gimprc.common b/plug-ins/common/gimprc.common
index ecbdb64552..6ae56d28f2 100644
--- a/plug-ins/common/gimprc.common
+++ b/plug-ins/common/gimprc.common
@@ -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
diff --git a/plug-ins/common/plugin-defs.pl b/plug-ins/common/plugin-defs.pl
index 79f9148513..8b2d60ca8b 100644
--- a/plug-ins/common/plugin-defs.pl
+++ b/plug-ins/common/plugin-defs.pl
@@ -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 },
diff --git a/po-plug-ins/POTFILES.in b/po-plug-ins/POTFILES.in
index acb41e2f1b..123fdaa450 100644
--- a/po-plug-ins/POTFILES.in
+++ b/po-plug-ins/POTFILES.in
@@ -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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]