mirror of https://github.com/GNOME/gimp.git
export the Colorize tool to the PDB. Fixes bug #154368.
2004-10-03 Sven Neumann <sven@gimp.org> * tools/pdbgen/pdb/color.pdb: export the Colorize tool to the PDB. Fixes bug #154368. * app/pdb/color_cmds.c * app/pdb/internal_procs.c * libgimp/gimpcolor_pdb.[ch]: regenerated.
This commit is contained in:
parent
cf9a815d1b
commit
9d2fdd95ea
|
@ -1,3 +1,12 @@
|
|||
2004-10-03 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* tools/pdbgen/pdb/color.pdb: export the Colorize tool to the PDB.
|
||||
Fixes bug #154368.
|
||||
|
||||
* app/pdb/color_cmds.c
|
||||
* app/pdb/internal_procs.c
|
||||
* libgimp/gimpcolor_pdb.[ch]: regenerated.
|
||||
|
||||
2004-10-03 DindinX <dindinx@gimp.org>
|
||||
|
||||
* plug-ins/common/blinds.c: use a GimpAspectPreview to make the
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include "procedural_db.h"
|
||||
|
||||
#include "base/color-balance.h"
|
||||
#include "base/colorize.h"
|
||||
#include "base/curves.h"
|
||||
#include "base/gimphistogram.h"
|
||||
#include "base/gimplut.h"
|
||||
|
@ -56,6 +57,7 @@ static ProcRecord invert_proc;
|
|||
static ProcRecord curves_spline_proc;
|
||||
static ProcRecord curves_explicit_proc;
|
||||
static ProcRecord color_balance_proc;
|
||||
static ProcRecord colorize_proc;
|
||||
static ProcRecord histogram_proc;
|
||||
static ProcRecord hue_saturation_proc;
|
||||
static ProcRecord threshold_proc;
|
||||
|
@ -73,6 +75,7 @@ register_color_procs (Gimp *gimp)
|
|||
procedural_db_register (gimp, &curves_spline_proc);
|
||||
procedural_db_register (gimp, &curves_explicit_proc);
|
||||
procedural_db_register (gimp, &color_balance_proc);
|
||||
procedural_db_register (gimp, &colorize_proc);
|
||||
procedural_db_register (gimp, &histogram_proc);
|
||||
procedural_db_register (gimp, &hue_saturation_proc);
|
||||
procedural_db_register (gimp, &threshold_proc);
|
||||
|
@ -1034,6 +1037,116 @@ static ProcRecord color_balance_proc =
|
|||
{ { color_balance_invoker } }
|
||||
};
|
||||
|
||||
static Argument *
|
||||
colorize_invoker (Gimp *gimp,
|
||||
GimpContext *context,
|
||||
GimpProgress *progress,
|
||||
Argument *args)
|
||||
{
|
||||
gboolean success = TRUE;
|
||||
GimpDrawable *drawable;
|
||||
gdouble hue;
|
||||
gdouble saturation;
|
||||
gdouble lightness;
|
||||
Colorize colors;
|
||||
PixelRegionIterator *pr;
|
||||
PixelRegion srcPR, destPR;
|
||||
gint x1, y1, x2, y2;
|
||||
|
||||
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;
|
||||
|
||||
hue = args[1].value.pdb_float;
|
||||
if (hue < 0.0 || hue > 360.0)
|
||||
success = FALSE;
|
||||
|
||||
saturation = args[2].value.pdb_float;
|
||||
if (saturation < 0.0 || saturation > 100.0)
|
||||
success = FALSE;
|
||||
|
||||
lightness = args[3].value.pdb_float;
|
||||
if (lightness < -100.0 || lightness > 100.0)
|
||||
success = FALSE;
|
||||
|
||||
if (success)
|
||||
{
|
||||
if (! gimp_drawable_is_rgb (drawable))
|
||||
success = FALSE;
|
||||
|
||||
if (success)
|
||||
{
|
||||
colorize_init (&colors);
|
||||
|
||||
colors.hue = hue;
|
||||
colors.saturation = saturation;
|
||||
colors.lightness = lightness;
|
||||
|
||||
colorize_calculate (&colors);
|
||||
|
||||
/* The application should occur only within selection bounds */
|
||||
gimp_drawable_mask_bounds (drawable, &x1, &y1, &x2, &y2);
|
||||
|
||||
pixel_region_init (&srcPR, gimp_drawable_data (drawable),
|
||||
x1, y1, (x2 - x1), (y2 - y1), FALSE);
|
||||
pixel_region_init (&destPR, gimp_drawable_shadow (drawable),
|
||||
x1, y1, (x2 - x1), (y2 - y1), TRUE);
|
||||
|
||||
for (pr = pixel_regions_register (2, &srcPR, &destPR);
|
||||
pr;
|
||||
pr = pixel_regions_process (pr))
|
||||
{
|
||||
colorize (&srcPR, &destPR, &colors);
|
||||
}
|
||||
|
||||
gimp_drawable_merge_shadow (drawable, TRUE, _("Colorize"));
|
||||
gimp_drawable_update (drawable, x1, y1, (x2 - x1), (y2 - y1));
|
||||
}
|
||||
}
|
||||
|
||||
return procedural_db_return_args (&colorize_proc, success);
|
||||
}
|
||||
|
||||
static ProcArg colorize_inargs[] =
|
||||
{
|
||||
{
|
||||
GIMP_PDB_DRAWABLE,
|
||||
"drawable",
|
||||
"The drawable"
|
||||
},
|
||||
{
|
||||
GIMP_PDB_FLOAT,
|
||||
"hue",
|
||||
"Hue in degrees: (0 <= hue <= 360)"
|
||||
},
|
||||
{
|
||||
GIMP_PDB_FLOAT,
|
||||
"saturation",
|
||||
"Saturation in percent: (0 <= saturation <= 100)"
|
||||
},
|
||||
{
|
||||
GIMP_PDB_FLOAT,
|
||||
"lightness",
|
||||
"Lightness in percent: (-100 <= lightness <= 100)"
|
||||
}
|
||||
};
|
||||
|
||||
static ProcRecord colorize_proc =
|
||||
{
|
||||
"gimp_colorize",
|
||||
"Render the drawable as a grayscale image seen through a colored glass.",
|
||||
"Desatures the drawable, then tints it with the specified color. This tool is only valid on RGB color images. It will not operate on grayscale or indexed drawables.",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"2004",
|
||||
GIMP_INTERNAL,
|
||||
4,
|
||||
colorize_inargs,
|
||||
0,
|
||||
NULL,
|
||||
{ { colorize_invoker } }
|
||||
};
|
||||
|
||||
static Argument *
|
||||
histogram_invoker (Gimp *gimp,
|
||||
GimpContext *context,
|
||||
|
|
|
@ -73,7 +73,7 @@ void register_transform_tools_procs (Gimp *gimp);
|
|||
void register_undo_procs (Gimp *gimp);
|
||||
void register_unit_procs (Gimp *gimp);
|
||||
|
||||
/* 407 procedures registered total */
|
||||
/* 408 procedures registered total */
|
||||
|
||||
void
|
||||
internal_procs_init (Gimp *gimp,
|
||||
|
@ -97,70 +97,70 @@ internal_procs_init (Gimp *gimp,
|
|||
(* status_callback) (NULL, _("Color"), 0.061);
|
||||
register_color_procs (gimp);
|
||||
|
||||
(* status_callback) (NULL, _("Context"), 0.093);
|
||||
(* status_callback) (NULL, _("Context"), 0.096);
|
||||
register_context_procs (gimp);
|
||||
|
||||
(* status_callback) (NULL, _("Convert"), 0.147);
|
||||
(* status_callback) (NULL, _("Convert"), 0.15);
|
||||
register_convert_procs (gimp);
|
||||
|
||||
(* status_callback) (NULL, _("Display procedures"), 0.155);
|
||||
(* status_callback) (NULL, _("Display procedures"), 0.157);
|
||||
register_display_procs (gimp);
|
||||
|
||||
(* status_callback) (NULL, _("Drawable procedures"), 0.165);
|
||||
(* status_callback) (NULL, _("Drawable procedures"), 0.167);
|
||||
register_drawable_procs (gimp);
|
||||
|
||||
(* status_callback) (NULL, _("Edit procedures"), 0.243);
|
||||
(* status_callback) (NULL, _("Edit procedures"), 0.245);
|
||||
register_edit_procs (gimp);
|
||||
|
||||
(* status_callback) (NULL, _("File Operations"), 0.263);
|
||||
(* status_callback) (NULL, _("File Operations"), 0.265);
|
||||
register_fileops_procs (gimp);
|
||||
|
||||
(* status_callback) (NULL, _("Floating selections"), 0.285);
|
||||
(* status_callback) (NULL, _("Floating selections"), 0.287);
|
||||
register_floating_sel_procs (gimp);
|
||||
|
||||
(* status_callback) (NULL, _("Font UI"), 0.3);
|
||||
(* status_callback) (NULL, _("Font UI"), 0.301);
|
||||
register_font_select_procs (gimp);
|
||||
|
||||
(* status_callback) (NULL, _("Fonts"), 0.307);
|
||||
(* status_callback) (NULL, _("Fonts"), 0.309);
|
||||
register_fonts_procs (gimp);
|
||||
|
||||
(* status_callback) (NULL, _("Gimprc procedures"), 0.312);
|
||||
(* status_callback) (NULL, _("Gimprc procedures"), 0.314);
|
||||
register_gimprc_procs (gimp);
|
||||
|
||||
(* status_callback) (NULL, _("Gradient"), 0.327);
|
||||
(* status_callback) (NULL, _("Gradient"), 0.328);
|
||||
register_gradient_procs (gimp);
|
||||
|
||||
(* status_callback) (NULL, _("Gradient UI"), 0.393);
|
||||
(* status_callback) (NULL, _("Gradient UI"), 0.395);
|
||||
register_gradient_select_procs (gimp);
|
||||
|
||||
(* status_callback) (NULL, _("Gradients"), 0.4);
|
||||
(* status_callback) (NULL, _("Gradients"), 0.402);
|
||||
register_gradients_procs (gimp);
|
||||
|
||||
(* status_callback) (NULL, _("Guide procedures"), 0.413);
|
||||
(* status_callback) (NULL, _("Guide procedures"), 0.414);
|
||||
register_guides_procs (gimp);
|
||||
|
||||
(* status_callback) (NULL, _("Help procedures"), 0.428);
|
||||
(* status_callback) (NULL, _("Help procedures"), 0.429);
|
||||
register_help_procs (gimp);
|
||||
|
||||
(* status_callback) (NULL, _("Image"), 0.43);
|
||||
(* status_callback) (NULL, _("Image"), 0.431);
|
||||
register_image_procs (gimp);
|
||||
|
||||
(* status_callback) (NULL, _("Layer"), 0.582);
|
||||
(* status_callback) (NULL, _("Layer"), 0.583);
|
||||
register_layer_procs (gimp);
|
||||
|
||||
(* status_callback) (NULL, _("Message procedures"), 0.646);
|
||||
(* status_callback) (NULL, _("Message procedures"), 0.647);
|
||||
register_message_procs (gimp);
|
||||
|
||||
(* status_callback) (NULL, _("Miscellaneous"), 0.654);
|
||||
register_misc_procs (gimp);
|
||||
|
||||
(* status_callback) (NULL, _("Paint Tool procedures"), 0.658);
|
||||
(* status_callback) (NULL, _("Paint Tool procedures"), 0.659);
|
||||
register_paint_tools_procs (gimp);
|
||||
|
||||
(* status_callback) (NULL, _("Palette"), 0.695);
|
||||
(* status_callback) (NULL, _("Palette"), 0.696);
|
||||
register_palette_procs (gimp);
|
||||
|
||||
(* status_callback) (NULL, _("Palette UI"), 0.722);
|
||||
(* status_callback) (NULL, _("Palette UI"), 0.723);
|
||||
register_palette_select_procs (gimp);
|
||||
|
||||
(* status_callback) (NULL, _("Palettes"), 0.73);
|
||||
|
@ -169,13 +169,13 @@ internal_procs_init (Gimp *gimp,
|
|||
(* status_callback) (NULL, _("Parasite procedures"), 0.74);
|
||||
register_parasite_procs (gimp);
|
||||
|
||||
(* status_callback) (NULL, _("Paths"), 0.769);
|
||||
(* status_callback) (NULL, _("Paths"), 0.77);
|
||||
register_paths_procs (gimp);
|
||||
|
||||
(* status_callback) (NULL, _("Pattern"), 0.806);
|
||||
register_pattern_procs (gimp);
|
||||
|
||||
(* status_callback) (NULL, _("Pattern UI"), 0.808);
|
||||
(* status_callback) (NULL, _("Pattern UI"), 0.809);
|
||||
register_pattern_select_procs (gimp);
|
||||
|
||||
(* status_callback) (NULL, _("Patterns"), 0.816);
|
||||
|
@ -190,10 +190,10 @@ internal_procs_init (Gimp *gimp,
|
|||
(* status_callback) (NULL, _("Progress"), 0.86);
|
||||
register_progress_procs (gimp);
|
||||
|
||||
(* status_callback) (NULL, _("Image mask"), 0.872);
|
||||
(* status_callback) (NULL, _("Image mask"), 0.873);
|
||||
register_selection_procs (gimp);
|
||||
|
||||
(* status_callback) (NULL, _("Selection Tool procedures"), 0.916);
|
||||
(* status_callback) (NULL, _("Selection Tool procedures"), 0.917);
|
||||
register_selection_tools_procs (gimp);
|
||||
|
||||
(* status_callback) (NULL, _("Text procedures"), 0.929);
|
||||
|
|
|
@ -426,6 +426,49 @@ gimp_color_balance (gint32 drawable_ID,
|
|||
return success;
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_colorize:
|
||||
* @drawable_ID: The drawable.
|
||||
* @hue: Hue in degrees.
|
||||
* @saturation: Saturation in percent.
|
||||
* @lightness: Lightness in percent.
|
||||
*
|
||||
* Render the drawable as a grayscale image seen through a colored
|
||||
* glass.
|
||||
*
|
||||
* Desatures the drawable, then tints it with the specified color. This
|
||||
* tool is only valid on RGB color images. It will not operate on
|
||||
* grayscale or indexed drawables.
|
||||
*
|
||||
* Returns: TRUE on success.
|
||||
*
|
||||
* Since: GIMP 2.2
|
||||
*/
|
||||
gboolean
|
||||
gimp_colorize (gint32 drawable_ID,
|
||||
gdouble hue,
|
||||
gdouble saturation,
|
||||
gdouble lightness)
|
||||
{
|
||||
GimpParam *return_vals;
|
||||
gint nreturn_vals;
|
||||
gboolean success = TRUE;
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp_colorize",
|
||||
&nreturn_vals,
|
||||
GIMP_PDB_DRAWABLE, drawable_ID,
|
||||
GIMP_PDB_FLOAT, hue,
|
||||
GIMP_PDB_FLOAT, saturation,
|
||||
GIMP_PDB_FLOAT, lightness,
|
||||
GIMP_PDB_END);
|
||||
|
||||
success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_histogram:
|
||||
* @drawable_ID: The drawable.
|
||||
|
|
|
@ -60,6 +60,10 @@ gboolean gimp_color_balance (gint32 drawable_ID,
|
|||
gdouble cyan_red,
|
||||
gdouble magenta_green,
|
||||
gdouble yellow_blue);
|
||||
gboolean gimp_colorize (gint32 drawable_ID,
|
||||
gdouble hue,
|
||||
gdouble saturation,
|
||||
gdouble lightness);
|
||||
gboolean gimp_histogram (gint32 drawable_ID,
|
||||
GimpHistogramChannel channel,
|
||||
gint start_range,
|
||||
|
|
|
@ -621,6 +621,71 @@ CODE
|
|||
);
|
||||
}
|
||||
|
||||
sub colorize {
|
||||
$blurb = 'Render the drawable as a grayscale image seen through a colored glass.';
|
||||
|
||||
$help = <<'HELP';
|
||||
Desatures the drawable, then tints it with the specified color. This tool is
|
||||
only valid on RGB color images. It will not operate on grayscale or indexed
|
||||
drawables.
|
||||
HELP
|
||||
|
||||
&std_pdb_misc;
|
||||
$date = '2004';
|
||||
$since = '2.2';
|
||||
|
||||
@inargs = (
|
||||
&drawable_arg,
|
||||
{ name => 'hue', type => '0 <= float <= 360',
|
||||
desc => 'Hue in degrees: (%%desc%%)' },
|
||||
{ name => 'saturation', type => '0 <= float <= 100',
|
||||
desc => 'Saturation in percent: (%%desc%%)' },
|
||||
{ name => 'lightness', type => '-100 <= float <= 100',
|
||||
desc => 'Lightness in percent: (%%desc%%)' }
|
||||
);
|
||||
|
||||
%invoke = (
|
||||
headers => [ qw("base/colorize.h") ],
|
||||
vars => [ 'Colorize colors', 'PixelRegionIterator *pr',
|
||||
'PixelRegion srcPR, destPR', 'gint x1, y1, x2, y2' ],
|
||||
code => <<'CODE'
|
||||
{
|
||||
if (! gimp_drawable_is_rgb (drawable))
|
||||
success = FALSE;
|
||||
|
||||
if (success)
|
||||
{
|
||||
colorize_init (&colors);
|
||||
|
||||
colors.hue = hue;
|
||||
colors.saturation = saturation;
|
||||
colors.lightness = lightness;
|
||||
|
||||
colorize_calculate (&colors);
|
||||
|
||||
/* The application should occur only within selection bounds */
|
||||
gimp_drawable_mask_bounds (drawable, &x1, &y1, &x2, &y2);
|
||||
|
||||
pixel_region_init (&srcPR, gimp_drawable_data (drawable),
|
||||
x1, y1, (x2 - x1), (y2 - y1), FALSE);
|
||||
pixel_region_init (&destPR, gimp_drawable_shadow (drawable),
|
||||
x1, y1, (x2 - x1), (y2 - y1), TRUE);
|
||||
|
||||
for (pr = pixel_regions_register (2, &srcPR, &destPR);
|
||||
pr;
|
||||
pr = pixel_regions_process (pr))
|
||||
{
|
||||
colorize (&srcPR, &destPR, &colors);
|
||||
}
|
||||
|
||||
gimp_drawable_merge_shadow (drawable, TRUE, _("Colorize"));
|
||||
gimp_drawable_update (drawable, x1, y1, (x2 - x1), (y2 - y1));
|
||||
}
|
||||
}
|
||||
CODE
|
||||
);
|
||||
}
|
||||
|
||||
sub histogram {
|
||||
$blurb = <<'BLURB';
|
||||
Returns information on the intensity histogram for the specified drawable.
|
||||
|
@ -831,14 +896,15 @@ CODE
|
|||
);
|
||||
}
|
||||
|
||||
@headers = qw("base/gimphistogram.h" "base/gimplut.h" "base/lut-funcs.h"
|
||||
@headers = qw("base/gimphistogram.h"
|
||||
"base/gimplut.h" "base/lut-funcs.h"
|
||||
"base/pixel-region.h" "base/pixel-processor.h"
|
||||
"core/gimpdrawable.h" "core/gimpimage.h"
|
||||
"gimp-intl.h");
|
||||
|
||||
@procs = qw(brightness_contrast levels levels_auto posterize desaturate
|
||||
equalize invert curves_spline curves_explicit color_balance
|
||||
histogram hue_saturation threshold);
|
||||
colorize histogram hue_saturation threshold);
|
||||
%exports = (app => [@procs], lib => [@procs]);
|
||||
|
||||
$desc = 'Color';
|
||||
|
|
Loading…
Reference in New Issue