Commit ae30cacd authored by Øyvind Kolås's avatar Øyvind Kolås

addition of white balance in menus, and related code reorganization

parent a27b0bff
2004-10-29 Øyvind Kolås <pippin@gimp.org>
* tools/pdbgen/pdb/color.pdb: moved body of code from here.
* app/core/gimpdrawable-levels.[ch]: to here.
* app/core/Makefile.am: added gimpdrawable-levels.[ch].
* app/pdb/color_cmds.c: regenerated.
* app/actions/drawable-actions.c
* app/actions/drawable-commands.[ch]: added drawable-layers-auto
action.
* app/widgets/gimphelp-ids.h: added GIMP_HELP_LAYER_WHITE_BALANCE.
* app/menus/image-menu.xml.in: added new auto/White Balance action.
* app/menus/image-menu.xml: regenerated.
2004-10-29 Sven Neumann <sven@gimp.org>
* app/widgets/gimpuimanager.c (gimp_ui_manager_entry_load)
......
......@@ -41,6 +41,11 @@
static GimpActionEntry drawable_actions[] =
{
{ "drawable-levels-auto", NULL,
N_("_White Balance"), NULL, NULL,
G_CALLBACK (drawable_levels_auto_cmd_callback),
GIMP_HELP_LAYER_WHITE_BALANCE},
{ "drawable-desaturate", GIMP_STOCK_CONVERT_GRAYSCALE,
N_("_Desaturate"), NULL, NULL,
G_CALLBACK (drawable_desaturate_cmd_callback),
......@@ -173,10 +178,11 @@ drawable_actions_update (GimpActionGroup *group,
#define SET_ACTIVE(action,condition) \
gimp_action_group_set_action_active (group, action, (condition) != 0)
SET_SENSITIVE ("drawable-desaturate", drawable && is_rgb);
SET_SENSITIVE ("drawable-equalize", drawable && ! is_indexed);
SET_SENSITIVE ("drawable-invert", drawable && ! is_indexed);
SET_SENSITIVE ("drawable-offset", drawable);
SET_SENSITIVE ("drawable-levels-auto", drawable && is_rgb);
SET_SENSITIVE ("drawable-desaturate", drawable && is_rgb);
SET_SENSITIVE ("drawable-equalize", drawable && ! is_indexed);
SET_SENSITIVE ("drawable-invert", drawable && ! is_indexed);
SET_SENSITIVE ("drawable-offset", drawable);
SET_SENSITIVE ("drawable-visible", drawable);
SET_SENSITIVE ("drawable-linked", drawable);
......
......@@ -28,6 +28,7 @@
#include "core/gimpdrawable-desaturate.h"
#include "core/gimpdrawable-equalize.h"
#include "core/gimpdrawable-invert.h"
#include "core/gimpdrawable-levels.h"
#include "core/gimpimage.h"
#include "core/gimpimage-undo.h"
#include "core/gimpitem-linked.h"
......@@ -44,6 +45,26 @@
/* public functions */
void
drawable_levels_auto_cmd_callback (GtkAction *action,
gpointer data)
{
GimpImage *gimage;
GimpDrawable *drawable;
GimpContext *context;
return_if_no_drawable (gimage, drawable, data);
return_if_no_context (context, data);
if (! gimp_drawable_is_rgb (drawable))
{
g_message (_("White Balance operates only on RGB color layers."));
return;
}
gimp_drawable_levels_auto (drawable, context);
gimp_image_flush (gimage);
}
void
drawable_desaturate_cmd_callback (GtkAction *action,
gpointer data)
......
......@@ -20,24 +20,26 @@
#define __DRAWABLE_COMMANDS_H__
void drawable_desaturate_cmd_callback (GtkAction *action,
gpointer data);
void drawable_equalize_cmd_callback (GtkAction *action,
gpointer data);
void drawable_flip_cmd_callback (GtkAction *action,
gint value,
gpointer data);
void drawable_invert_cmd_callback (GtkAction *action,
gpointer data);
void drawable_linked_cmd_callback (GtkAction *action,
gpointer data);
void drawable_offset_cmd_callback (GtkAction *action,
gpointer data);
void drawable_rotate_cmd_callback (GtkAction *action,
gint value,
gpointer data);
void drawable_visible_cmd_callback (GtkAction *action,
gpointer data);
void drawable_levels_auto_cmd_callback (GtkAction *action,
gpointer data);
void drawable_desaturate_cmd_callback (GtkAction *action,
gpointer data);
void drawable_equalize_cmd_callback (GtkAction *action,
gpointer data);
void drawable_flip_cmd_callback (GtkAction *action,
gint value,
gpointer data);
void drawable_invert_cmd_callback (GtkAction *action,
gpointer data);
void drawable_linked_cmd_callback (GtkAction *action,
gpointer data);
void drawable_offset_cmd_callback (GtkAction *action,
gpointer data);
void drawable_rotate_cmd_callback (GtkAction *action,
gint value,
gpointer data);
void drawable_visible_cmd_callback (GtkAction *action,
gpointer data);
#endif /* __DRAWABLE_COMMANDS_H__ */
......@@ -89,6 +89,8 @@ libappcore_a_sources = \
gimpdrawable-histogram.h \
gimpdrawable-invert.c \
gimpdrawable-invert.h \
gimpdrawable-levels.c \
gimpdrawable-levels.h \
gimpdrawable-offset.c \
gimpdrawable-offset.h \
gimpdrawable-preview.c \
......
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <string.h>
#include <glib-object.h>
#include "core-types.h"
#include "base/gimphistogram.h"
#include "base/gimplut.h"
#include "base/levels.h"
#include "base/lut-funcs.h"
#include "base/pixel-processor.h"
#include "base/pixel-region.h"
#include "config/gimpbaseconfig.h"
#include "gimp.h"
#include "gimpcontext.h"
#include "gimpdrawable.h"
#include "gimpdrawable-histogram.h"
#include "gimpdrawable-levels.h"
#include "gimp-intl.h"
void
gimp_drawable_levels (GimpDrawable *drawable,
GimpContext *context,
gint32 channel,
gint32 low_input,
gint32 high_input,
gdouble gamma,
gint32 low_output,
gint32 high_output)
{
gint x, y, width, height;
PixelRegion srcPR, destPR;
Levels levels;
GimpLut *lut;
/* parameter checking */
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
g_return_if_fail (channel >= GIMP_HISTOGRAM_VALUE &&
channel <= GIMP_HISTOGRAM_ALPHA);
g_return_if_fail (low_input >= 0 && low_input <= 255);
g_return_if_fail (high_input >= 0 && high_input <= 255);
g_return_if_fail (gamma >= 0.1 && gamma <= 10.0);
g_return_if_fail (low_output >= 0 && low_output <= 255);
g_return_if_fail (high_output >= 0 && high_output <= 255);
g_return_if_fail (!gimp_drawable_is_indexed (drawable));
if (channel == GIMP_HISTOGRAM_ALPHA)
g_return_if_fail (gimp_drawable_has_alpha (drawable));
if (gimp_drawable_is_gray (drawable))
g_return_if_fail (channel == GIMP_HISTOGRAM_VALUE ||
channel == GIMP_HISTOGRAM_ALPHA);
if (!gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
return;
/* FIXME: hack */
if (gimp_drawable_is_gray (drawable) &&
channel == GIMP_HISTOGRAM_ALPHA)
channel = 1;
lut = gimp_lut_new ();
levels_init (&levels);
levels.low_input[channel] = low_input;
levels.high_input[channel] = high_input;
levels.gamma[channel] = gamma;
levels.low_output[channel] = low_output;
levels.high_output[channel] = high_output;
/* setup the lut */
gimp_lut_setup (lut,
(GimpLutFunc) levels_lut_func,
&levels,
gimp_drawable_bytes (drawable));
pixel_region_init (&srcPR, gimp_drawable_data (drawable),
x, y, width, height, FALSE);
pixel_region_init (&destPR, gimp_drawable_shadow (drawable),
x, y, width, height, TRUE);
pixel_regions_process_parallel ((p_func) gimp_lut_process, lut, 2,
&srcPR, &destPR);
gimp_lut_free (lut);
gimp_drawable_merge_shadow (drawable, TRUE, _("Levels"));
gimp_drawable_update (drawable, x, y, width, height);
}
void
gimp_drawable_levels_auto (GimpDrawable *drawable,
GimpContext *context)
{
gint x, y, width, height;
PixelRegion srcPR, destPR;
Levels levels;
GimpLut *lut;
GimpHistogram *hist;
/* parameter checking */
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
g_return_if_fail (GIMP_IS_CONTEXT (context));
if (gimp_drawable_is_indexed (drawable))
return;
if (!gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
return;
/* Build the histogram */
hist = gimp_histogram_new (GIMP_BASE_CONFIG (context->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));
pixel_region_init (&srcPR, gimp_drawable_data (drawable),
x, y, width, height, FALSE);
pixel_region_init (&destPR, gimp_drawable_shadow (drawable),
x, y, width, height, 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, x, y, width, height);
}
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __GIMP_DRAWABLE_LEVELS_H__
#define __GIMP_DRAWABLE_LEVELS_H__
void
gimp_drawable_levels (GimpDrawable *drawable,
GimpContext *context,
gint32 channel,
gint32 low_input,
gint32 high_input,
gdouble gamma,
gint32 low_output,
gint32 high_output);
void
gimp_drawable_levels_auto (GimpDrawable *drawable,
GimpContext *context);
#endif /* __GIMP_DRAWABLE_LEVELS_H__ */
......@@ -43,6 +43,7 @@
#include "core/gimpdrawable-equalize.h"
#include "core/gimpdrawable-histogram.h"
#include "core/gimpdrawable-invert.h"
#include "core/gimpdrawable-levels.h"
#include "core/gimpdrawable.h"
#include "core/gimpimage.h"
#include "gimp-intl.h"
......@@ -231,51 +232,13 @@ levels_invoker (Gimp *gimp,
success = FALSE;
if (success)
{
gint x, y, width, height;
/* The application should occur only within selection bounds */
if (gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
{
PixelRegion srcPR, destPR;
Levels l;
GimpLut *lut;
/* FIXME: hack */
if (gimp_drawable_is_gray (drawable) &&
channel == GIMP_HISTOGRAM_ALPHA)
channel = 1;
lut = gimp_lut_new ();
levels_init (&l);
l.low_input[channel] = low_input;
l.high_input[channel] = high_input;
l.gamma[channel] = gamma;
l.low_output[channel] = low_output;
l.high_output[channel] = high_output;
/* setup the lut */
gimp_lut_setup (lut,
(GimpLutFunc) levels_lut_func,
&l,
gimp_drawable_bytes (drawable));
pixel_region_init (&srcPR, gimp_drawable_data (drawable),
x, y, width, height, FALSE);
pixel_region_init (&destPR, gimp_drawable_shadow (drawable),
x, y, width, height, TRUE);
pixel_regions_process_parallel ((p_func) gimp_lut_process, lut, 2,
&srcPR, &destPR);
gimp_lut_free (lut);
gimp_drawable_merge_shadow (drawable, TRUE, _("Levels"));
gimp_drawable_update (drawable, x, y, width, height);
}
}
gimp_drawable_levels (drawable, context,
channel,
low_input,
high_input,
gamma,
low_output,
high_output);
}
return procedural_db_return_args (&levels_proc, success);
......@@ -356,48 +319,7 @@ levels_auto_invoker (Gimp *gimp,
success = FALSE;
if (success)
{
gint x, y, width, height;
/* The application should occur only within selection bounds */
if (gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
{
PixelRegion srcPR, destPR;
Levels levels;
GimpLut *lut;
GimpHistogram *hist;
/* Build the histogram */
hist = gimp_histogram_new (GIMP_BASE_CONFIG (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));
pixel_region_init (&srcPR, gimp_drawable_data (drawable),
x, y, width, height, FALSE);
pixel_region_init (&destPR, gimp_drawable_shadow (drawable),
x, y, width, height, 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, x, y, width, height);
}
}
gimp_drawable_levels_auto (drawable, context);
}
return procedural_db_return_args (&levels_auto_proc, success);
......
......@@ -140,6 +140,7 @@
#define GIMP_HELP_LAYER_LOWER_TO_BOTTOM "gimp-layer-lower-to-bottom"
#define GIMP_HELP_LAYER_DESATURATE "gimp-layer-desaturate"
#define GIMP_HELP_LAYER_INVERT "gimp-layer-invert"
#define GIMP_HELP_LAYER_WHITE_BALANCE "gimp-layer-white-balance"
#define GIMP_HELP_LAYER_EQUALIZE "gimp-layer-equalize"
#define GIMP_HELP_LAYER_VISIBLE "gimp-layer-visible"
#define GIMP_HELP_LAYER_LINKED "gimp-layer-linked"
......
......@@ -344,6 +344,7 @@
<menuitem action="drawable-invert" />
<menu action="layers-colors-auto-menu" name="Auto">
<menuitem action="drawable-equalize" />
<menuitem action="drawable-levels-auto" />
</menu>
<separator />
<placeholder name="Info">
......
2004-10-29 Øyvind Kolås <pippin@gimp.org>
* POTFILES.in: added app/core/gimpdrawable-levels.c
2004-10-27 Adam Weinberger <adamw@gnome.org>
* en_CA.po: Updated Canadian English translation.
......
......@@ -92,6 +92,7 @@ app/core/gimpdrawable-bucket-fill.c
app/core/gimpdrawable-desaturate.c
app/core/gimpdrawable-equalize.c
app/core/gimpdrawable-invert.c
app/core/gimpdrawable-levels.c
app/core/gimpdrawable-offset.c
app/core/gimpdrawable-stroke.c
app/core/gimpdrawable-transform.c
......
......@@ -121,7 +121,8 @@ HELP
$#inargs--;
%invoke = (
headers => [ qw("base/levels.h") ],
headers => [ qw("base/levels.h"
"core/gimpdrawable-levels.h") ],
code => <<'CODE'
{
if (gimp_drawable_is_indexed (drawable) ||
......@@ -132,51 +133,13 @@ HELP
success = FALSE;
if (success)
{
gint x, y, width, height;
/* The application should occur only within selection bounds */
if (gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
{
PixelRegion srcPR, destPR;
Levels l;
GimpLut *lut;
/* FIXME: hack */
if (gimp_drawable_is_gray (drawable) &&
channel == GIMP_HISTOGRAM_ALPHA)
channel = 1;
lut = gimp_lut_new ();
levels_init (&l);
l.low_input[channel] = low_input;
l.high_input[channel] = high_input;
l.gamma[channel] = gamma;
l.low_output[channel] = low_output;
l.high_output[channel] = high_output;
/* setup the lut */
gimp_lut_setup (lut,
(GimpLutFunc) levels_lut_func,
&l,
gimp_drawable_bytes (drawable));
pixel_region_init (&srcPR, gimp_drawable_data (drawable),
x, y, width, height, FALSE);
pixel_region_init (&destPR, gimp_drawable_shadow (drawable),
x, y, width, height, TRUE);
pixel_regions_process_parallel ((p_func) gimp_lut_process, lut, 2,
&srcPR, &destPR);
gimp_lut_free (lut);
gimp_drawable_merge_shadow (drawable, TRUE, _("Levels"));
gimp_drawable_update (drawable, x, y, width, height);
}
}
gimp_drawable_levels (drawable, context,
channel,
low_input,
high_input,
gamma,
low_output,
high_output);
}
CODE
);
......@@ -201,56 +164,17 @@ HELP
@inargs = ( &drawable_arg );
%invoke = (
headers => [ qw("base/levels.h" "base/gimphistogram.h"
"core/gimpdrawable-histogram.h") ],
headers => [ qw("base/levels.h"
"base/gimphistogram.h"
"core/gimpdrawable-histogram.h"
"core/gimpdrawable-levels.h") ],
code => <<'CODE'
{
if (gimp_drawable_is_indexed (drawable))
success = FALSE;
if (success)
{
gint x, y, width, height;
/* The application should occur only within selection bounds */
if (gimp_drawable_mask_intersect (drawable, &x, &y, &width, &height))
{
PixelRegion srcPR, destPR;
Levels levels;
GimpLut *lut;
GimpHistogram *hist;
/* Build the histogram */
hist = gimp_histogram_new (GIMP_BASE_CONFIG (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));
pixel_region_init (&srcPR, gimp_drawable_data (drawable),
x, y, width, height, FALSE);
pixel_region_init (&destPR, gimp_drawable_shadow (drawable),
x, y, width, height, 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, x, y, width, height);
}
}
gimp_drawable_levels_auto (drawable, context);
}
CODE
);
......
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