From c4832468a103740b6f1e7053bb9e959f0210e69d Mon Sep 17 00:00:00 2001 From: Michael Natterer Date: Tue, 19 Apr 2005 20:31:30 +0000 Subject: [PATCH] applied patch from Karine Delvare which adds gimp_desaturate_full(). Fixes 2005-04-19 Michael Natterer * tools/pdbgen/pdb/color.pdb: applied patch from Karine Delvare which adds gimp_desaturate_full(). Fixes bug #155507. * app/pdb/color_cmds.c * app/pdb/internal_procs.c * libgimp/gimpcolor_pdb.[ch]: regenerated. * libgimp/gimp.def: added the new symbol. --- ChangeLog | 11 +++++++ app/pdb/color_cmds.c | 64 ++++++++++++++++++++++++++++++++++++++ app/pdb/internal_procs.c | 56 ++++++++++++++++----------------- libgimp/gimp.def | 1 + libgimp/gimpcolor_pdb.c | 37 ++++++++++++++++++++++ libgimp/gimpcolor_pdb.h | 2 ++ tools/pdbgen/pdb/color.pdb | 38 ++++++++++++++++++++-- 7 files changed, 179 insertions(+), 30 deletions(-) diff --git a/ChangeLog b/ChangeLog index f600d39a9e..76a08e7bbd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2005-04-19 Michael Natterer + + * tools/pdbgen/pdb/color.pdb: applied patch from Karine Delvare + which adds gimp_desaturate_full(). Fixes bug #155507. + + * app/pdb/color_cmds.c + * app/pdb/internal_procs.c + * libgimp/gimpcolor_pdb.[ch]: regenerated. + + * libgimp/gimp.def: added the new symbol. + 2005-04-19 Michael Natterer * app/core/gimpimage-snap.c: bail out early if the coords are diff --git a/app/pdb/color_cmds.c b/app/pdb/color_cmds.c index 1b19e90eb6..46dc5a9815 100644 --- a/app/pdb/color_cmds.c +++ b/app/pdb/color_cmds.c @@ -53,6 +53,7 @@ static ProcRecord levels_auto_proc; static ProcRecord levels_stretch_proc; static ProcRecord posterize_proc; static ProcRecord desaturate_proc; +static ProcRecord desaturate_full_proc; static ProcRecord equalize_proc; static ProcRecord invert_proc; static ProcRecord curves_spline_proc; @@ -72,6 +73,7 @@ register_color_procs (Gimp *gimp) procedural_db_register (gimp, &levels_stretch_proc); procedural_db_register (gimp, &posterize_proc); procedural_db_register (gimp, &desaturate_proc); + procedural_db_register (gimp, &desaturate_full_proc); procedural_db_register (gimp, &equalize_proc); procedural_db_register (gimp, &invert_proc); procedural_db_register (gimp, &curves_spline_proc); @@ -547,6 +549,68 @@ static ProcRecord desaturate_proc = { { desaturate_invoker } } }; +static Argument * +desaturate_full_invoker (Gimp *gimp, + GimpContext *context, + GimpProgress *progress, + Argument *args) +{ + gboolean success = TRUE; + GimpDrawable *drawable; + gint32 desaturate_mode; + + drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int); + if (! (GIMP_IS_DRAWABLE (drawable) && ! gimp_item_is_removed (GIMP_ITEM (drawable)))) + success = FALSE; + + desaturate_mode = args[1].value.pdb_int; + if (desaturate_mode < GIMP_DESATURATE_LIGHTNESS || desaturate_mode > GIMP_DESATURATE_AVERAGE) + success = FALSE; + + if (success) + { + if (! gimp_item_is_attached (GIMP_ITEM (drawable)) || + ! gimp_drawable_is_rgb (drawable)) + success = FALSE; + + if (success) + gimp_drawable_desaturate (drawable, (GimpDesaturateMode) desaturate_mode); + } + + return procedural_db_return_args (&desaturate_full_proc, success); +} + +static ProcArg desaturate_full_inargs[] = +{ + { + GIMP_PDB_DRAWABLE, + "drawable", + "The drawable" + }, + { + GIMP_PDB_INT32, + "desaturate_mode", + "The formula to use to desaturate" + } +}; + +static ProcRecord desaturate_full_proc = +{ + "gimp_desaturate_full", + "Desaturate the contents of the specified drawable, with the specified formula.", + "This procedure desaturates the contents of the specified drawable, with the specified formula. This procedure only works on drawables of type RGB color.", + "Karine Delvare", + "Karine Delvare", + "2005", + NULL, + GIMP_INTERNAL, + 2, + desaturate_full_inargs, + 0, + NULL, + { { desaturate_full_invoker } } +}; + static Argument * equalize_invoker (Gimp *gimp, GimpContext *context, diff --git a/app/pdb/internal_procs.c b/app/pdb/internal_procs.c index f5389d286c..bf6ff8d237 100644 --- a/app/pdb/internal_procs.c +++ b/app/pdb/internal_procs.c @@ -75,7 +75,7 @@ void register_undo_procs (Gimp *gimp); void register_unit_procs (Gimp *gimp); void register_vectors_procs (Gimp *gimp); -/* 458 procedures registered total */ +/* 459 procedures registered total */ void internal_procs_init (Gimp *gimp, @@ -90,82 +90,82 @@ internal_procs_init (Gimp *gimp, (* status_callback) (NULL, _("Brush UI"), 0.048); register_brush_select_procs (gimp); - (* status_callback) (NULL, _("Brushes"), 0.055); + (* status_callback) (NULL, _("Brushes"), 0.054); register_brushes_procs (gimp); (* status_callback) (NULL, _("Channel"), 0.068); register_channel_procs (gimp); - (* status_callback) (NULL, _("Color"), 0.09); + (* status_callback) (NULL, _("Color"), 0.089); register_color_procs (gimp); - (* status_callback) (NULL, _("Context"), 0.122); + (* status_callback) (NULL, _("Context"), 0.124); register_context_procs (gimp); - (* status_callback) (NULL, _("Convert"), 0.17); + (* status_callback) (NULL, _("Convert"), 0.172); register_convert_procs (gimp); - (* status_callback) (NULL, _("Display procedures"), 0.177); + (* status_callback) (NULL, _("Display procedures"), 0.179); register_display_procs (gimp); - (* status_callback) (NULL, _("Drawable procedures"), 0.186); + (* status_callback) (NULL, _("Drawable procedures"), 0.187); register_drawable_procs (gimp); - (* status_callback) (NULL, _("Transformation procedures"), 0.26); + (* status_callback) (NULL, _("Transformation procedures"), 0.261); register_drawable_transform_procs (gimp); - (* status_callback) (NULL, _("Edit procedures"), 0.295); + (* status_callback) (NULL, _("Edit procedures"), 0.296); register_edit_procs (gimp); - (* status_callback) (NULL, _("File Operations"), 0.314); + (* status_callback) (NULL, _("File Operations"), 0.316); register_fileops_procs (gimp); - (* status_callback) (NULL, _("Floating selections"), 0.336); + (* status_callback) (NULL, _("Floating selections"), 0.338); register_floating_sel_procs (gimp); - (* status_callback) (NULL, _("Font UI"), 0.349); + (* status_callback) (NULL, _("Font UI"), 0.351); register_font_select_procs (gimp); - (* status_callback) (NULL, _("Fonts"), 0.356); + (* status_callback) (NULL, _("Fonts"), 0.357); register_fonts_procs (gimp); - (* status_callback) (NULL, _("Gimprc procedures"), 0.36); + (* status_callback) (NULL, _("Gimprc procedures"), 0.362); register_gimprc_procs (gimp); - (* status_callback) (NULL, _("Gradient"), 0.373); + (* status_callback) (NULL, _("Gradient"), 0.375); register_gradient_procs (gimp); - (* status_callback) (NULL, _("Gradient UI"), 0.439); + (* status_callback) (NULL, _("Gradient UI"), 0.44); register_gradient_select_procs (gimp); - (* status_callback) (NULL, _("Gradients"), 0.445); + (* status_callback) (NULL, _("Gradients"), 0.447); register_gradients_procs (gimp); - (* status_callback) (NULL, _("Guide procedures"), 0.456); + (* status_callback) (NULL, _("Guide procedures"), 0.458); register_guides_procs (gimp); - (* status_callback) (NULL, _("Help procedures"), 0.469); + (* status_callback) (NULL, _("Help procedures"), 0.471); register_help_procs (gimp); - (* status_callback) (NULL, _("Image"), 0.472); + (* status_callback) (NULL, _("Image"), 0.473); register_image_procs (gimp); - (* status_callback) (NULL, _("Layer"), 0.609); + (* status_callback) (NULL, _("Layer"), 0.61); register_layer_procs (gimp); - (* status_callback) (NULL, _("Message procedures"), 0.668); + (* status_callback) (NULL, _("Message procedures"), 0.669); register_message_procs (gimp); (* status_callback) (NULL, _("Miscellaneous"), 0.675); register_misc_procs (gimp); - (* status_callback) (NULL, _("Paint Tool procedures"), 0.679); + (* status_callback) (NULL, _("Paint Tool procedures"), 0.68); register_paint_tools_procs (gimp); (* status_callback) (NULL, _("Palette"), 0.712); register_palette_procs (gimp); - (* status_callback) (NULL, _("Palette UI"), 0.742); + (* status_callback) (NULL, _("Palette UI"), 0.743); register_palette_select_procs (gimp); (* status_callback) (NULL, _("Palettes"), 0.749); @@ -180,13 +180,13 @@ internal_procs_init (Gimp *gimp, (* status_callback) (NULL, _("Pattern"), 0.819); register_pattern_procs (gimp); - (* status_callback) (NULL, _("Pattern UI"), 0.823); + (* status_callback) (NULL, _("Pattern UI"), 0.824); register_pattern_select_procs (gimp); (* status_callback) (NULL, _("Patterns"), 0.83); register_patterns_procs (gimp); - (* status_callback) (NULL, _("Plug-in"), 0.838); + (* status_callback) (NULL, _("Plug-in"), 0.839); register_plug_in_procs (gimp); (* status_callback) (NULL, _("Procedural database"), 0.852); @@ -195,13 +195,13 @@ internal_procs_init (Gimp *gimp, (* status_callback) (NULL, _("Progress"), 0.871); register_progress_procs (gimp); - (* status_callback) (NULL, _("Image mask"), 0.886); + (* status_callback) (NULL, _("Image mask"), 0.887); register_selection_procs (gimp); (* status_callback) (NULL, _("Selection Tool procedures"), 0.924); register_selection_tools_procs (gimp); - (* status_callback) (NULL, _("Text procedures"), 0.934); + (* status_callback) (NULL, _("Text procedures"), 0.935); register_text_tool_procs (gimp); (* status_callback) (NULL, _("Transform Tool procedures"), 0.943); diff --git a/libgimp/gimp.def b/libgimp/gimp.def index 057d74e712..a06b47140c 100644 --- a/libgimp/gimp.def +++ b/libgimp/gimp.def @@ -91,6 +91,7 @@ EXPORTS gimp_curves_spline gimp_default_display gimp_desaturate + gimp_desaturate_full gimp_destroy_paramdefs gimp_destroy_params gimp_display_delete diff --git a/libgimp/gimpcolor_pdb.c b/libgimp/gimpcolor_pdb.c index 694cf268b3..f3ea127896 100644 --- a/libgimp/gimpcolor_pdb.c +++ b/libgimp/gimpcolor_pdb.c @@ -243,6 +243,43 @@ gimp_desaturate (gint32 drawable_ID) return success; } +/** + * gimp_desaturate_full: + * @drawable_ID: The drawable. + * @desaturate_mode: The formula to use to desaturate. + * + * Desaturate the contents of the specified drawable, with the + * specified formula. + * + * This procedure desaturates the contents of the specified drawable, + * with the specified formula. This procedure only works on drawables + * of type RGB color. + * + * Returns: TRUE on success. + * + * Since: GIMP 2.4 + */ +gboolean +gimp_desaturate_full (gint32 drawable_ID, + GimpDesaturateMode desaturate_mode) +{ + GimpParam *return_vals; + gint nreturn_vals; + gboolean success = TRUE; + + return_vals = gimp_run_procedure ("gimp_desaturate_full", + &nreturn_vals, + GIMP_PDB_DRAWABLE, drawable_ID, + GIMP_PDB_INT32, desaturate_mode, + GIMP_PDB_END); + + success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS; + + gimp_destroy_params (return_vals, nreturn_vals); + + return success; +} + /** * gimp_equalize: * @drawable_ID: The drawable. diff --git a/libgimp/gimpcolor_pdb.h b/libgimp/gimpcolor_pdb.h index ed24cf667f..b658370d7c 100644 --- a/libgimp/gimpcolor_pdb.h +++ b/libgimp/gimpcolor_pdb.h @@ -46,6 +46,8 @@ gboolean gimp_levels_stretch (gint32 drawable_ID); gboolean gimp_posterize (gint32 drawable_ID, gint levels); gboolean gimp_desaturate (gint32 drawable_ID); +gboolean gimp_desaturate_full (gint32 drawable_ID, + GimpDesaturateMode desaturate_mode); gboolean gimp_equalize (gint32 drawable_ID, gboolean mask_only); gboolean gimp_invert (gint32 drawable_ID); diff --git a/tools/pdbgen/pdb/color.pdb b/tools/pdbgen/pdb/color.pdb index 757a6a7527..001e88b594 100644 --- a/tools/pdbgen/pdb/color.pdb +++ b/tools/pdbgen/pdb/color.pdb @@ -290,6 +290,39 @@ CODE ); } +sub desaturate_full { + $blurb = 'Desaturate the contents of the specified drawable, with the specified formula.'; + + $help = <<'HELP'; +This procedure desaturates the contents of the specified drawable, with the specified +formula. This procedure only works on drawables of type RGB color. +HELP + + $author = $copyright = 'Karine Delvare'; + $date = '2005'; + $since = '2.4'; + + @inargs = ( + &drawable_arg, + { name => 'desaturate_mode', type => 'enum GimpDesaturateMode', + desc => 'The formula to use to desaturate' } + ); + + %invoke = ( + headers => [ qw("core/gimpdrawable-desaturate.h") ], + code => <<'CODE' +{ + if (! gimp_item_is_attached (GIMP_ITEM (drawable)) || + ! gimp_drawable_is_rgb (drawable)) + success = FALSE; + + if (success) + gimp_drawable_desaturate (drawable, (GimpDesaturateMode) desaturate_mode); +} +CODE + ); +} + sub equalize { $blurb = 'Equalize the contents of the specified drawable.'; @@ -898,8 +931,9 @@ CODE "gimp-intl.h"); @procs = qw(brightness_contrast levels levels_auto levels_stretch posterize - desaturate equalize invert curves_spline curves_explicit - color_balance colorize histogram hue_saturation threshold); + desaturate desaturate_full equalize invert curves_spline + curves_explicit color_balance colorize histogram hue_saturation + threshold); %exports = (app => [@procs], lib => [@procs]); $desc = 'Color';