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

plug-ins, pdb: remove the color-exchange plug-in

and add a PDB compat procedure.
parent 48899803
......@@ -28,7 +28,7 @@
#include "internal-procs.h"
/* 733 procedures registered total */
/* 734 procedures registered total */
void
internal_procs_init (GimpPDB *pdb)
......
......@@ -940,6 +940,80 @@ plug_in_deinterlace_invoker (GimpProcedure *procedure,
error ? *error : NULL);
}
static GimpValueArray *
plug_in_exchange_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GimpValueArray *args,
GError **error)
{
gboolean success = TRUE;
GimpDrawable *drawable;
guint8 from_red;
guint8 from_green;
guint8 from_blue;
guint8 to_red;
guint8 to_green;
guint8 to_blue;
guint8 red_threshold;
guint8 green_threshold;
guint8 blue_threshold;
drawable = gimp_value_get_drawable (gimp_value_array_index (args, 2), gimp);
from_red = g_value_get_uint (gimp_value_array_index (args, 3));
from_green = g_value_get_uint (gimp_value_array_index (args, 4));
from_blue = g_value_get_uint (gimp_value_array_index (args, 5));
to_red = g_value_get_uint (gimp_value_array_index (args, 6));
to_green = g_value_get_uint (gimp_value_array_index (args, 7));
to_blue = g_value_get_uint (gimp_value_array_index (args, 8));
red_threshold = g_value_get_uint (gimp_value_array_index (args, 9));
green_threshold = g_value_get_uint (gimp_value_array_index (args, 10));
blue_threshold = g_value_get_uint (gimp_value_array_index (args, 11));
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))
{
GimpRGB from;
GimpRGB to;
GeglColor *gegl_from;
GeglColor *gegl_to;
GeglNode *node;
gimp_rgb_set_uchar (&from, from_red, from_green, from_blue);
gimp_rgb_set_uchar (&to, to_red, to_green, to_blue);
gegl_from = gimp_gegl_color_new (&from);
gegl_to = gimp_gegl_color_new (&to);
node = gegl_node_new_child (NULL,
"operation", "gegl:color-exchange",
"from-color", gegl_from,
"to-color", gegl_to,
"red-threshold", red_threshold / 255.0,
"green-threshold", green_threshold / 255.0,
"blue-threshold", blue_threshold / 255.0,
NULL);
g_object_unref (gegl_from);
g_object_unref (gegl_to);
gimp_drawable_apply_operation (drawable, progress,
C_("undo-type", "Color Exchange"),
node);
g_object_unref (node);
}
else
success = FALSE;
}
return gimp_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static GimpValueArray *
plug_in_gauss_invoker (GimpProcedure *procedure,
Gimp *gimp,
......@@ -3258,6 +3332,96 @@ register_plug_in_compat_procs (GimpPDB *pdb)
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* gimp-plug-in-exchange
*/
procedure = gimp_procedure_new (plug_in_exchange_invoker);
gimp_object_set_static_name (GIMP_OBJECT (procedure),
"plug-in-exchange");
gimp_procedure_set_static_strings (procedure,
"plug-in-exchange",
"Swap one color with another",
"Exchange one color with another, optionally setting a threshold to convert from one shade to another.",
"Compatibility procedure. Please see 'gegl:color-exchange' for credits.",
"Compatibility procedure. Please see 'gegl:color-exchange' 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,
gimp_param_spec_int8 ("from-red",
"from red",
"Red value (from)",
0, G_MAXUINT8, 0,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
gimp_param_spec_int8 ("from-green",
"from green",
"Green value (from)",
0, G_MAXUINT8, 0,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
gimp_param_spec_int8 ("from-blue",
"from blue",
"Blue value (from)",
0, G_MAXUINT8, 0,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
gimp_param_spec_int8 ("to-red",
"to red",
"Red value (to)",
0, G_MAXUINT8, 0,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
gimp_param_spec_int8 ("to-green",
"to green",
"Green value (to)",
0, G_MAXUINT8, 0,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
gimp_param_spec_int8 ("to-blue",
"to blue",
"Blue value (to)",
0, G_MAXUINT8, 0,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
gimp_param_spec_int8 ("red-threshold",
"red threshold",
"Red threshold",
0, G_MAXUINT8, 0,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
gimp_param_spec_int8 ("green-threshold",
"green threshold",
"Green threshold",
0, G_MAXUINT8, 0,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
gimp_param_spec_int8 ("blue-threshold",
"blue threshold",
"Blue threshold",
0, G_MAXUINT8, 0,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* gimp-plug-in-gauss
*/
......
......@@ -28,8 +28,6 @@
/color-cube-analyze.exe
/color-enhance
/color-enhance.exe
/color-exchange
/color-exchange.exe
/colorify
/colorify.exe
/colormap-remap
......
......@@ -57,7 +57,6 @@ libexec_PROGRAMS = \
cml-explorer \
color-cube-analyze \
color-enhance \
color-exchange \
colorify \
colormap-remap \
compose \
......@@ -408,23 +407,6 @@ color_enhance_LDADD = \
$(INTLLIBS) \
$(color_enhance_RC)
color_exchange_SOURCES = \
color-exchange.c
color_exchange_LDADD = \
$(libgimpui) \
$(libgimpwidgets) \
$(libgimpmodule) \
$(libgimp) \
$(libgimpmath) \
$(libgimpconfig) \
$(libgimpcolor) \
$(libgimpbase) \
$(GTK_LIBS) \
$(RT_LIBS) \
$(INTLLIBS) \
$(color_exchange_RC)
colorify_SOURCES = \
colorify.c
......
This diff is collapsed.
......@@ -11,7 +11,6 @@ checkerboard_RC = checkerboard.rc.o
cml_explorer_RC = cml-explorer.rc.o
color_cube_analyze_RC = color-cube-analyze.rc.o
color_enhance_RC = color-enhance.rc.o
color_exchange_RC = color-exchange.rc.o
colorify_RC = colorify.rc.o
colormap_remap_RC = colormap-remap.rc.o
compose_RC = compose.rc.o
......
......@@ -12,7 +12,6 @@
'cml-explorer' => { ui => 1 },
'color-cube-analyze' => { ui => 1 },
'color-enhance' => { ui => 1 },
'color-exchange' => { ui => 1 },
'colorify' => { ui => 1 },
'colormap-remap' => { ui => 1, gegl => 1 },
'compose' => { ui => 1, gegl => 1 },
......
......@@ -16,7 +16,6 @@ plug-ins/common/checkerboard.c
plug-ins/common/cml-explorer.c
plug-ins/common/color-cube-analyze.c
plug-ins/common/color-enhance.c
plug-ins/common/color-exchange.c
plug-ins/common/colorify.c
plug-ins/common/colormap-remap.c
plug-ins/common/compose.c
......
......@@ -844,6 +844,88 @@ CODE
);
}
sub plug_in_exchange {
$blurb = 'Swap one color with another';
$help = <<'HELP';
Exchange one color with another, optionally setting a threshold to
convert from one shade to another.
HELP
&std_pdb_compat('gegl:color-exchange');
$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 => 'from_red', type => 'int8',
desc => 'Red value (from)' },
{ name => 'from_green', type => 'int8',
desc => 'Green value (from)' },
{ name => 'from_blue', type => 'int8',
desc => 'Blue value (from)' },
{ name => 'to_red', type => 'int8',
desc => 'Red value (to)' },
{ name => 'to_green', type => 'int8',
desc => 'Green value (to)' },
{ name => 'to_blue', type => 'int8',
desc => 'Blue value (to)' },
{ name => 'red_threshold', type => 'int8',
desc => 'Red threshold' },
{ name => 'green_threshold', type => 'int8',
desc => 'Green threshold' },
{ name => 'blue_threshold', type => 'int8',
desc => 'Blue threshold' }
);
%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))
{
GimpRGB from;
GimpRGB to;
GeglColor *gegl_from;
GeglColor *gegl_to;
GeglNode *node;
gimp_rgb_set_uchar (&from, from_red, from_green, from_blue);
gimp_rgb_set_uchar (&to, to_red, to_green, to_blue);
gegl_from = gimp_gegl_color_new (&from);
gegl_to = gimp_gegl_color_new (&to);
node = gegl_node_new_child (NULL,
"operation", "gegl:color-exchange",
"from-color", gegl_from,
"to-color", gegl_to,
"red-threshold", red_threshold / 255.0,
"green-threshold", green_threshold / 255.0,
"blue-threshold", blue_threshold / 255.0,
NULL);
g_object_unref (gegl_from);
g_object_unref (gegl_to);
gimp_drawable_apply_operation (drawable, progress,
C_("undo-type", "Color Exchange"),
node);
g_object_unref (node);
}
else
success = FALSE;
}
CODE
);
}
sub plug_in_gauss {
$blurb = 'Simplest, most commonly used way of blurring';
......@@ -2890,6 +2972,7 @@ CODE
plug_in_convmatrix
plug_in_cubism
plug_in_deinterlace
plug_in_exchange
plug_in_gauss
plug_in_gauss_iir
plug_in_gauss_iir2
......
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