mirror of
https://gitlab.gnome.org/GNOME/gimp.git
synced 2025-07-03 17:33:25 +00:00
pdb: add a PDB procedure for extract-component
This commit is contained in:
parent
1905197983
commit
dbf9f277a2
5 changed files with 181 additions and 0 deletions
|
@ -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;
|
||||
guint8 component;
|
||||
gboolean invert;
|
||||
gboolean linear;
|
||||
|
||||
drawable = gimp_value_get_drawable (gimp_value_array_index (args, 0), gimp);
|
||||
component = g_value_get_uint (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,
|
||||
|
@ -1010,6 +1057,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_strings (procedure,
|
||||
"gimp-drawable-extract-component",
|
||||
"Extract a color model component.",
|
||||
"Extract a color model component.",
|
||||
"",
|
||||
"",
|
||||
"2021",
|
||||
NULL);
|
||||
gimp_procedure_add_argument (procedure,
|
||||
gimp_param_spec_drawable_id ("drawable",
|
||||
"drawable",
|
||||
"The drawable",
|
||||
pdb->gimp, FALSE,
|
||||
GIMP_PARAM_READWRITE));
|
||||
gimp_procedure_add_argument (procedure,
|
||||
gimp_param_spec_int8 ("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
|
||||
*/
|
||||
|
|
|
@ -222,6 +222,7 @@ EXPORTS
|
|||
gimp_drawable_edit_stroke_item
|
||||
gimp_drawable_edit_stroke_selection
|
||||
gimp_drawable_equalize
|
||||
gimp_drawable_extract_component
|
||||
gimp_drawable_fill
|
||||
gimp_drawable_flush
|
||||
gimp_drawable_foreground_extract
|
||||
|
|
|
@ -260,6 +260,44 @@ gimp_drawable_curves_spline (gint32 drawable_ID,
|
|||
return success;
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_drawable_extract_component:
|
||||
* @drawable_ID: 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 (gint32 drawable_ID,
|
||||
guint8 component,
|
||||
gboolean invert,
|
||||
gboolean linear)
|
||||
{
|
||||
GimpParam *return_vals;
|
||||
gint nreturn_vals;
|
||||
gboolean success = TRUE;
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp-drawable-extract-component",
|
||||
&nreturn_vals,
|
||||
GIMP_PDB_DRAWABLE, drawable_ID,
|
||||
GIMP_PDB_INT8, component,
|
||||
GIMP_PDB_INT32, invert,
|
||||
GIMP_PDB_INT32, linear,
|
||||
GIMP_PDB_END);
|
||||
|
||||
success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_drawable_desaturate:
|
||||
* @drawable_ID: The drawable.
|
||||
|
|
|
@ -53,6 +53,10 @@ gboolean gimp_drawable_curves_spline (gint32 drawable_ID,
|
|||
GimpHistogramChannel channel,
|
||||
gint num_points,
|
||||
const gdouble *points);
|
||||
gboolean gimp_drawable_extract_component (gint32 drawable_ID,
|
||||
guint8 component,
|
||||
gboolean invert,
|
||||
gboolean linear);
|
||||
gboolean gimp_drawable_desaturate (gint32 drawable_ID,
|
||||
GimpDesaturateMode desaturate_mode);
|
||||
gboolean gimp_drawable_equalize (gint32 drawable_ID,
|
||||
|
|
|
@ -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 <= int8 <= 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.
|
||||
|
@ -886,6 +935,7 @@ CODE
|
|||
drawable_colorize_hsl
|
||||
drawable_curves_explicit
|
||||
drawable_curves_spline
|
||||
drawable_extract_component
|
||||
drawable_desaturate
|
||||
drawable_equalize
|
||||
drawable_histogram
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue