mirror of https://github.com/GNOME/gimp.git
pdb: add a PDB procedure for extract-component
(cherry picked from commit dbf9f277a2
)
Committer's (Jehan) updates:
- Component type is now int32 (int8 is not a PDB type available anymore).
- PDB files re-generated to handle changes in API and types.
This commit is contained in:
parent
d1eb30d863
commit
acdf5a3776
|
@ -293,6 +293,53 @@ drawable_curves_spline_invoker (GimpProcedure *procedure,
|
|||
error ? *error : NULL);
|
||||
}
|
||||
|
||||
static GimpValueArray *
|
||||
drawable_extract_component_invoker (GimpProcedure *procedure,
|
||||
Gimp *gimp,
|
||||
GimpContext *context,
|
||||
GimpProgress *progress,
|
||||
const GimpValueArray *args,
|
||||
GError **error)
|
||||
{
|
||||
gboolean success = TRUE;
|
||||
GimpDrawable *drawable;
|
||||
gint component;
|
||||
gboolean invert;
|
||||
gboolean linear;
|
||||
|
||||
drawable = g_value_get_object (gimp_value_array_index (args, 0));
|
||||
component = g_value_get_int (gimp_value_array_index (args, 1));
|
||||
invert = g_value_get_boolean (gimp_value_array_index (args, 2));
|
||||
linear = g_value_get_boolean (gimp_value_array_index (args, 3));
|
||||
|
||||
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) &&
|
||||
gimp_drawable_is_rgb (drawable))
|
||||
{
|
||||
GeglNode *node =
|
||||
gegl_node_new_child (NULL,
|
||||
"operation", "gegl:component-extract",
|
||||
"component", component,
|
||||
"invert", invert,
|
||||
"linear", linear,
|
||||
NULL);
|
||||
|
||||
gimp_drawable_apply_operation (drawable, progress,
|
||||
C_("undo-type", "Extract Component"),
|
||||
node);
|
||||
g_object_unref (node);
|
||||
}
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
|
||||
return gimp_procedure_get_return_values (procedure, success,
|
||||
error ? *error : NULL);
|
||||
}
|
||||
|
||||
static GimpValueArray *
|
||||
drawable_desaturate_invoker (GimpProcedure *procedure,
|
||||
Gimp *gimp,
|
||||
|
@ -1002,6 +1049,47 @@ register_drawable_color_procs (GimpPDB *pdb)
|
|||
gimp_pdb_register_procedure (pdb, procedure);
|
||||
g_object_unref (procedure);
|
||||
|
||||
/*
|
||||
* gimp-drawable-extract-component
|
||||
*/
|
||||
procedure = gimp_procedure_new (drawable_extract_component_invoker);
|
||||
gimp_object_set_static_name (GIMP_OBJECT (procedure),
|
||||
"gimp-drawable-extract-component");
|
||||
gimp_procedure_set_static_help (procedure,
|
||||
"Extract a color model component.",
|
||||
"Extract a color model component.",
|
||||
NULL);
|
||||
gimp_procedure_set_static_attribution (procedure,
|
||||
"",
|
||||
"",
|
||||
"2021");
|
||||
gimp_procedure_add_argument (procedure,
|
||||
gimp_param_spec_drawable ("drawable",
|
||||
"drawable",
|
||||
"The drawable",
|
||||
FALSE,
|
||||
GIMP_PARAM_READWRITE));
|
||||
gimp_procedure_add_argument (procedure,
|
||||
g_param_spec_int ("component",
|
||||
"component",
|
||||
"Commponent (RGB Red (0), RGB Green (1), RGB Blue (2), Hue (3), HSV Saturation (4), HSV Value (5), HSL Saturation (6), HSL Lightness (7), CMYK Cyan (8), CMYK Magenta (9), CMYK Yellow (10), CMYK Key (11), Y'CbCr Y' (12), Y'CbCr Cb (13), Y'CbCr Cr (14), LAB L (15), LAB A (16), LAB B (17), LCH C(ab) (18), LCH H(ab) (19), Alpha (20))",
|
||||
0, 20, 0,
|
||||
GIMP_PARAM_READWRITE));
|
||||
gimp_procedure_add_argument (procedure,
|
||||
g_param_spec_boolean ("invert",
|
||||
"invert",
|
||||
"Invert the extracted component",
|
||||
FALSE,
|
||||
GIMP_PARAM_READWRITE));
|
||||
gimp_procedure_add_argument (procedure,
|
||||
g_param_spec_boolean ("linear",
|
||||
"linear",
|
||||
"Use linear output instead of gamma corrected",
|
||||
FALSE,
|
||||
GIMP_PARAM_READWRITE));
|
||||
gimp_pdb_register_procedure (pdb, procedure);
|
||||
g_object_unref (procedure);
|
||||
|
||||
/*
|
||||
* gimp-drawable-desaturate
|
||||
*/
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
#include "internal-procs.h"
|
||||
|
||||
|
||||
/* 773 procedures registered total */
|
||||
/* 774 procedures registered total */
|
||||
|
||||
void
|
||||
internal_procs_init (GimpPDB *pdb)
|
||||
|
|
|
@ -211,6 +211,7 @@ EXPORTS
|
|||
gimp_drawable_edit_stroke_item
|
||||
gimp_drawable_edit_stroke_selection
|
||||
gimp_drawable_equalize
|
||||
gimp_drawable_extract_component
|
||||
gimp_drawable_fill
|
||||
gimp_drawable_foreground_extract
|
||||
gimp_drawable_free_shadow
|
||||
|
|
|
@ -285,6 +285,48 @@ gimp_drawable_curves_spline (GimpDrawable *drawable,
|
|||
return success;
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_drawable_extract_component:
|
||||
* @drawable: The drawable.
|
||||
* @component: Commponent (RGB Red (0), RGB Green (1), RGB Blue (2), Hue (3), HSV Saturation (4), HSV Value (5), HSL Saturation (6), HSL Lightness (7), CMYK Cyan (8), CMYK Magenta (9), CMYK Yellow (10), CMYK Key (11), Y'CbCr Y' (12), Y'CbCr Cb (13), Y'CbCr Cr (14), LAB L (15), LAB A (16), LAB B (17), LCH C(ab) (18), LCH H(ab) (19), Alpha (20)).
|
||||
* @invert: Invert the extracted component.
|
||||
* @linear: Use linear output instead of gamma corrected.
|
||||
*
|
||||
* Extract a color model component.
|
||||
*
|
||||
* Extract a color model component.
|
||||
*
|
||||
* Returns: TRUE on success.
|
||||
**/
|
||||
gboolean
|
||||
gimp_drawable_extract_component (GimpDrawable *drawable,
|
||||
gint component,
|
||||
gboolean invert,
|
||||
gboolean linear)
|
||||
{
|
||||
GimpValueArray *args;
|
||||
GimpValueArray *return_vals;
|
||||
gboolean success = TRUE;
|
||||
|
||||
args = gimp_value_array_new_from_types (NULL,
|
||||
GIMP_TYPE_DRAWABLE, drawable,
|
||||
G_TYPE_INT, component,
|
||||
G_TYPE_BOOLEAN, invert,
|
||||
G_TYPE_BOOLEAN, linear,
|
||||
G_TYPE_NONE);
|
||||
|
||||
return_vals = gimp_pdb_run_procedure_array (gimp_get_pdb (),
|
||||
"gimp-drawable-extract-component",
|
||||
args);
|
||||
gimp_value_array_unref (args);
|
||||
|
||||
success = GIMP_VALUES_GET_ENUM (return_vals, 0) == GIMP_PDB_SUCCESS;
|
||||
|
||||
gimp_value_array_unref (return_vals);
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_drawable_desaturate:
|
||||
* @drawable: The drawable.
|
||||
|
|
|
@ -53,6 +53,10 @@ gboolean gimp_drawable_curves_spline (GimpDrawable *drawable,
|
|||
GimpHistogramChannel channel,
|
||||
gint num_points,
|
||||
const gdouble *points);
|
||||
gboolean gimp_drawable_extract_component (GimpDrawable *drawable,
|
||||
gint component,
|
||||
gboolean invert,
|
||||
gboolean linear);
|
||||
gboolean gimp_drawable_desaturate (GimpDrawable *drawable,
|
||||
GimpDesaturateMode desaturate_mode);
|
||||
gboolean gimp_drawable_equalize (GimpDrawable *drawable,
|
||||
|
|
|
@ -292,6 +292,55 @@ CODE
|
|||
);
|
||||
}
|
||||
|
||||
sub drawable_extract_component {
|
||||
$blurb = 'Extract a color model component.';
|
||||
|
||||
$help = 'Extract a color model component.';
|
||||
|
||||
$date = '2021';
|
||||
|
||||
@inargs = (
|
||||
{ name => 'drawable', type => 'drawable',
|
||||
desc => 'The drawable' },
|
||||
{ name => 'component', type => '0 <= int32 <= 20',
|
||||
desc => 'Commponent (RGB Red (0), RGB Green (1), RGB Blue (2), Hue (3), HSV Saturation (4), HSV Value (5),' .
|
||||
' HSL Saturation (6), HSL Lightness (7), CMYK Cyan (8), CMYK Magenta (9), CMYK Yellow (10), CMYK Key (11),' .
|
||||
' Y\'CbCr Y\' (12), Y\'CbCr Cb (13), Y\'CbCr Cr (14), LAB L (15), LAB A (16), LAB B (17), LCH C(ab) (18),' .
|
||||
' LCH H(ab) (19), Alpha (20))' },
|
||||
{ name => 'invert', type => 'boolean',
|
||||
desc => 'Invert the extracted component' },
|
||||
{ name => 'linear', type => 'boolean',
|
||||
desc => 'Use linear output instead of gamma corrected' }
|
||||
);
|
||||
|
||||
%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) &&
|
||||
gimp_drawable_is_rgb (drawable))
|
||||
{
|
||||
GeglNode *node =
|
||||
gegl_node_new_child (NULL,
|
||||
"operation", "gegl:component-extract",
|
||||
"component", component,
|
||||
"invert", invert,
|
||||
"linear", linear,
|
||||
NULL);
|
||||
|
||||
gimp_drawable_apply_operation (drawable, progress,
|
||||
C_("undo-type", "Extract Component"),
|
||||
node);
|
||||
g_object_unref (node);
|
||||
}
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
CODE
|
||||
);
|
||||
}
|
||||
|
||||
sub drawable_desaturate {
|
||||
$blurb = <<'BLURB';
|
||||
Desaturate the contents of the specified drawable, with the specified formula.
|
||||
|
@ -876,6 +925,7 @@ CODE
|
|||
drawable_colorize_hsl
|
||||
drawable_curves_explicit
|
||||
drawable_curves_spline
|
||||
drawable_extract_component
|
||||
drawable_desaturate
|
||||
drawable_equalize
|
||||
drawable_histogram
|
||||
|
|
Loading…
Reference in New Issue