Commit dbc4b46e authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann

applied a patch from Shawn Willden that adds the new PDB function

2003-08-31  Sven Neumann  <sven@gimp.org>

	* tools/pdbgen/pdb/color.pdb: applied a patch from Shawn Willden
	that adds the new PDB function levels_auto.

	* app/pdb/color_cmds.c
	* app/pdb/internal_procs.c
	* libgimp/gimpcolor_pdb.[ch]: regenerated.
parent f03a72cd
2003-08-31 Sven Neumann <sven@gimp.org>
* tools/pdbgen/pdb/color.pdb: applied a patch from Shawn Willden
that adds the new PDB function levels_auto.
* app/pdb/color_cmds.c
* app/pdb/internal_procs.c
* libgimp/gimpcolor_pdb.[ch]: regenerated.
2003-08-31 Raphael Quinet <quinet@gamers.org>
* data/palettes/Makefile.am (palettedata_DATA): fixed the spelling
......@@ -49,6 +49,7 @@
static ProcRecord brightness_contrast_proc;
static ProcRecord levels_proc;
static ProcRecord levels_auto_proc;
static ProcRecord posterize_proc;
static ProcRecord desaturate_proc;
static ProcRecord equalize_proc;
......@@ -65,6 +66,7 @@ register_color_procs (Gimp *gimp)
{
procedural_db_register (gimp, &brightness_contrast_proc);
procedural_db_register (gimp, &levels_proc);
procedural_db_register (gimp, &levels_auto_proc);
procedural_db_register (gimp, &posterize_proc);
procedural_db_register (gimp, &desaturate_proc);
procedural_db_register (gimp, &equalize_proc);
......@@ -314,6 +316,93 @@ static ProcRecord levels_proc =
{ { levels_invoker } }
};
static Argument *
levels_auto_invoker (Gimp *gimp,
Argument *args)
{
gboolean success = TRUE;
GimpDrawable *drawable;
PixelRegion srcPR, destPR;
Levels levels;
gint x1, y1, x2, y2;
GimpLut *lut;
GimpImage *image;
GimpHistogram *hist;
drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! GIMP_IS_DRAWABLE (drawable))
success = FALSE;
if (success)
{
if (gimp_drawable_is_indexed (drawable))
success = FALSE;
if (success)
{
/* Build the histogram */
image = gimp_item_get_image (GIMP_ITEM (drawable));
hist = gimp_histogram_new (image->gimp->config);
gimp_drawable_calculate_histogram (drawable, hist);
/* Calculate the levels */
levels_init (&levels);
levels_auto (&levels, hist, !gimp_drawable_is_gray (drawable));
/* Set up the lut */
lut = gimp_lut_new ();
gimp_lut_setup (lut,
(GimpLutFunc) levels_lut_func,
&levels,
gimp_drawable_bytes (drawable));
/* 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);
pixel_regions_process_parallel ((p_func) gimp_lut_process, lut, 2,
&srcPR, &destPR);
gimp_lut_free (lut);
gimp_histogram_free (hist);
gimp_drawable_merge_shadow (drawable, TRUE, _("Levels"));
gimp_drawable_update (drawable, x1, y1, (x2 - x1), (y2 - y1));
}
}
return procedural_db_return_args (&levels_auto_proc, success);
}
static ProcArg levels_auto_inargs[] =
{
{
GIMP_PDB_DRAWABLE,
"drawable",
"The drawable"
}
};
static ProcRecord levels_auto_proc =
{
"gimp_levels_auto",
"Automatically modifies intensity levels in the specified drawable.",
"This procedure allows intensity levels in the specified drawable to be remapped according to a set of guessed parameters. It is equivalent to clicking the \"Auto\" button in the Levels tool. This procedure is only valid on RGB color and grayscale images. It will not operate on indexed drawables.",
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996",
GIMP_INTERNAL,
1,
levels_auto_inargs,
0,
NULL,
{ { levels_auto_invoker } }
};
static Argument *
posterize_invoker (Gimp *gimp,
Argument *args)
......
......@@ -68,7 +68,7 @@ void register_transform_tools_procs (Gimp *gimp);
void register_undo_procs (Gimp *gimp);
void register_unit_procs (Gimp *gimp);
/* 344 procedures registered total */
/* 345 procedures registered total */
void
internal_procs_init (Gimp *gimp,
......@@ -89,88 +89,88 @@ internal_procs_init (Gimp *gimp,
(* status_callback) (NULL, _("Color"), 0.087);
register_color_procs (gimp);
(* status_callback) (NULL, _("Convert"), 0.122);
(* status_callback) (NULL, _("Convert"), 0.125);
register_convert_procs (gimp);
(* status_callback) (NULL, _("Display procedures"), 0.131);
(* status_callback) (NULL, _("Display procedures"), 0.133);
register_display_procs (gimp);
(* status_callback) (NULL, _("Drawable procedures"), 0.142);
(* status_callback) (NULL, _("Drawable procedures"), 0.145);
register_drawable_procs (gimp);
(* status_callback) (NULL, _("Edit procedures"), 0.209);
(* status_callback) (NULL, _("Edit procedures"), 0.212);
register_edit_procs (gimp);
(* status_callback) (NULL, _("File Operations"), 0.227);
(* status_callback) (NULL, _("File Operations"), 0.229);
register_fileops_procs (gimp);
(* status_callback) (NULL, _("Floating selections"), 0.25);
(* status_callback) (NULL, _("Floating selections"), 0.252);
register_floating_sel_procs (gimp);
(* status_callback) (NULL, _("Font UI"), 0.267);
(* status_callback) (NULL, _("Font UI"), 0.27);
register_font_select_procs (gimp);
(* status_callback) (NULL, _("Gimprc procedures"), 0.276);
(* status_callback) (NULL, _("Gimprc procedures"), 0.278);
register_gimprc_procs (gimp);
(* status_callback) (NULL, _("Gradient UI"), 0.288);
(* status_callback) (NULL, _("Gradient UI"), 0.29);
register_gradient_select_procs (gimp);
(* status_callback) (NULL, _("Gradients"), 0.297);
(* status_callback) (NULL, _("Gradients"), 0.299);
register_gradients_procs (gimp);
(* status_callback) (NULL, _("Guide procedures"), 0.317);
(* status_callback) (NULL, _("Guide procedures"), 0.319);
register_guides_procs (gimp);
(* status_callback) (NULL, _("Help procedures"), 0.334);
(* status_callback) (NULL, _("Help procedures"), 0.336);
register_help_procs (gimp);
(* status_callback) (NULL, _("Image"), 0.337);
(* status_callback) (NULL, _("Image"), 0.339);
register_image_procs (gimp);
(* status_callback) (NULL, _("Layer"), 0.523);
(* status_callback) (NULL, _("Layer"), 0.525);
register_layer_procs (gimp);
(* status_callback) (NULL, _("Message procedures"), 0.616);
(* status_callback) (NULL, _("Message procedures"), 0.617);
register_message_procs (gimp);
(* status_callback) (NULL, _("Miscellaneous"), 0.625);
(* status_callback) (NULL, _("Miscellaneous"), 0.626);
register_misc_procs (gimp);
(* status_callback) (NULL, _("Misc Tool procedures"), 0.631);
(* status_callback) (NULL, _("Misc Tool procedures"), 0.632);
register_misc_tools_procs (gimp);
(* status_callback) (NULL, _("Paint Tool procedures"), 0.64);
(* status_callback) (NULL, _("Paint Tool procedures"), 0.641);
register_paint_tools_procs (gimp);
(* status_callback) (NULL, _("Palette"), 0.683);
(* status_callback) (NULL, _("Palette"), 0.684);
register_palette_procs (gimp);
(* status_callback) (NULL, _("Palette UI"), 0.701);
register_palette_select_procs (gimp);
(* status_callback) (NULL, _("Palettes"), 0.709);
(* status_callback) (NULL, _("Palettes"), 0.71);
register_palettes_procs (gimp);
(* status_callback) (NULL, _("Parasite procedures"), 0.724);
(* status_callback) (NULL, _("Parasite procedures"), 0.725);
register_parasite_procs (gimp);
(* status_callback) (NULL, _("Paths"), 0.759);
register_paths_procs (gimp);
(* status_callback) (NULL, _("Pattern UI"), 0.799);
(* status_callback) (NULL, _("Pattern UI"), 0.8);
register_pattern_select_procs (gimp);
(* status_callback) (NULL, _("Patterns"), 0.808);
(* status_callback) (NULL, _("Patterns"), 0.809);
register_patterns_procs (gimp);
(* status_callback) (NULL, _("Plug-in"), 0.823);
register_plug_in_procs (gimp);
(* status_callback) (NULL, _("Procedural database"), 0.84);
(* status_callback) (NULL, _("Procedural database"), 0.841);
register_procedural_db_procs (gimp);
(* status_callback) (NULL, _("Image mask"), 0.863);
(* status_callback) (NULL, _("Image mask"), 0.864);
register_selection_procs (gimp);
(* status_callback) (NULL, _("Selection Tool procedures"), 0.916);
......
2003-08-31 Sven Neumann <sven@gimp.org>
* libgimp/libgimp-sections.txt
* libgimp/tmpl/gimpcolor.sgml: updated for new PDB function.
2003-08-28 Sven Neumann <sven@gimp.org>
* app/app.interfaces: removed, it's a generated file.
......
......@@ -142,6 +142,7 @@ gimp_channel_combine_masks
<FILE>gimpcolor</FILE>
gimp_brightness_contrast
gimp_levels
gimp_levels_auto
gimp_posterize
gimp_desaturate
gimp_equalize
......
......@@ -41,6 +41,15 @@ Functions for manipulating color, including curves and histograms.
@Returns:
<!-- ##### FUNCTION gimp_levels_auto ##### -->
<para>
</para>
@drawable_ID:
@Returns:
<!-- ##### FUNCTION gimp_posterize ##### -->
<para>
......
......@@ -120,6 +120,39 @@ gimp_levels (gint32 drawable_ID,
return success;
}
/**
* gimp_levels_auto:
* @drawable_ID: The drawable.
*
* Automatically modifies intensity levels in the specified drawable.
*
* This procedure allows intensity levels in the specified drawable to
* be remapped according to a set of guessed parameters. It is
* equivalent to clicking the \"Auto\" button in the Levels tool. This
* procedure is only valid on RGB color and grayscale images. It will
* not operate on indexed drawables.
*
* Returns: TRUE on success.
*/
gboolean
gimp_levels_auto (gint32 drawable_ID)
{
GimpParam *return_vals;
gint nreturn_vals;
gboolean success = TRUE;
return_vals = gimp_run_procedure ("gimp_levels_auto",
&nreturn_vals,
GIMP_PDB_DRAWABLE, drawable_ID,
GIMP_PDB_END);
success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
gimp_destroy_params (return_vals, nreturn_vals);
return success;
}
/**
* gimp_posterize:
* @drawable_ID: The drawable.
......
......@@ -39,6 +39,7 @@ gboolean gimp_levels (gint32 drawable_ID,
gdouble gamma,
gint low_output,
gint high_output);
gboolean gimp_levels_auto (gint32 drawable_ID);
gboolean gimp_posterize (gint32 drawable_ID,
gint levels);
gboolean gimp_desaturate (gint32 drawable_ID);
......
......@@ -165,6 +165,77 @@ CODE
);
}
sub levels_auto {
$blurb = 'Automatically modifies intensity levels in the specified drawable.';
$help = <<'HELP';
This procedure allows intensity levels in the specified drawable to be
remapped according to a set of guessed parameters. It is equivalent to
clicking the "Auto" button in the Levels tool. This procedure is
only valid on RGB color and grayscale images. It will not operate on
indexed drawables.
HELP
$author = $copyright = 'Joao S.O. Bueno, Shawn Willden';
$date = '2003';
&std_pdb_misc;
@inargs = ( &drawable_arg );
%invoke = (
headers => [ qw("base/levels.h" "base/gimphistogram.h") ],
vars => [ 'PixelRegion srcPR, destPR',
'Levels levels',
'gint x1, y1, x2, y2',
'GimpLut *lut',
'GimpImage *image',
'GimpHistogram *hist' ],
code => <<'CODE'
{
if (gimp_drawable_is_indexed (drawable))
success = FALSE;
if (success)
{
/* Build the histogram */
image = gimp_item_get_image (GIMP_ITEM (drawable));
hist = gimp_histogram_new (image->gimp->config);
gimp_drawable_calculate_histogram (drawable, hist);
/* Calculate the levels */
levels_init (&levels);
levels_auto (&levels, hist, !gimp_drawable_is_gray (drawable));
/* Set up the lut */
lut = gimp_lut_new ();
gimp_lut_setup (lut,
(GimpLutFunc) levels_lut_func,
&levels,
gimp_drawable_bytes (drawable));
/* 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);
pixel_regions_process_parallel ((p_func) gimp_lut_process, lut, 2,
&srcPR, &destPR);
gimp_lut_free (lut);
gimp_histogram_free (hist);
gimp_drawable_merge_shadow (drawable, TRUE, _("Levels"));
gimp_drawable_update (drawable, x1, y1, (x2 - x1), (y2 - y1));
}
}
CODE
);
}
sub posterize {
$blurb = 'Posterize the specified drawable.';
......@@ -741,9 +812,9 @@ CODE
"core/gimpdrawable.h" "core/gimpimage.h"
"gimp-intl.h");
@procs = qw(brightness_contrast levels posterize desaturate equalize invert
curves_spline curves_explicit color_balance histogram
hue_saturation threshold);
@procs = qw(brightness_contrast levels levels_auto posterize desaturate
equalize invert curves_spline curves_explicit color_balance
histogram hue_saturation threshold);
%exports = (app => [@procs], lib => [@procs]);
$desc = 'Color';
......
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