1997-11-25 06:05:25 +08:00
|
|
|
/* 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
|
1998-04-13 13:44:11 +08:00
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
1997-11-25 06:05:25 +08:00
|
|
|
*/
|
2000-02-14 06:26:41 +08:00
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
1999-08-27 08:19:25 +08:00
|
|
|
#include <stdio.h>
|
1997-11-25 06:05:25 +08:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
1999-08-27 08:19:25 +08:00
|
|
|
#include <errno.h>
|
2000-02-14 06:26:41 +08:00
|
|
|
|
2002-01-30 22:54:27 +08:00
|
|
|
#ifdef __GNUC__
|
|
|
|
#warning GTK_DISABLE_DEPRECATED
|
|
|
|
#endif
|
|
|
|
#undef GTK_DISABLE_DEPRECATED
|
|
|
|
|
2000-12-29 23:22:01 +08:00
|
|
|
#include <gtk/gtk.h>
|
2000-12-17 05:37:03 +08:00
|
|
|
|
2001-05-22 04:30:16 +08:00
|
|
|
#include "libgimpbase/gimpbase.h"
|
2001-01-25 06:36:18 +08:00
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
2001-01-24 07:56:18 +08:00
|
|
|
|
2002-05-03 20:45:22 +08:00
|
|
|
#include "tools-types.h"
|
2001-05-25 07:57:08 +08:00
|
|
|
|
|
|
|
#include "base/gimphistogram.h"
|
|
|
|
#include "base/gimplut.h"
|
More color correction stuff cleanup:
2002-09-04 Michael Natterer <mitch@gimp.org>
More color correction stuff cleanup:
* app/base/Makefile.am
* app/base/base-types.h
* app/base/levels.[ch]: new files containing levels_lut_func(), a
new "Levels" parameter struct and the "auto levels" stuff.
* app/base/lut-funcs.[ch]: removed the levels stuff here, added
lots of g_return_if_fail().
* app/base/color-balance.[ch]
* app/base/hue-saturation.[ch]: added init() and reset() functions
so we don't need to duplicate this code in the tool and the pdb
wrappers.
* app/base/curves.[ch]: s/gint/GimpHistogramChannel/g, made
curves_channel_reset() initialize the curves array.
* app/tools/gimpcolorbalancetool.[ch]: use the new functions,
moved the "Range" frame to the top, added a per-range "Reset"
button, made the global "Reset" button reset all ranges and
the "Preserve Luminosity" toggle.
* app/tools/gimpcurvestool.[ch]: don't initialize the curves
array manually, as curves_channel_reset() does that,
s/gint/GimpHistogramChannel/g.
* app/tools/gimphuesaturationtool.c: use the new functions, added
a per-channel "Reset" button and made the global "Reset" button
reset all channels, cleaned up the GUI update function.
* app/tools/gimplevelstool.[ch]: changed to use the new Levels
parameter struct and it's utility functions. Removed stuff
which now lives in base/levels.c
* app/tools/gimpimagemaptool.c: align the "Preview" button
bottom-left, not bottom-right.
* tools/pdbgen/pdb/color.pdb: use the new stuff and removed
uglyness because using the "Levels" struct makes the code more
straightforward.
* app/pdb/color_cmds.c: regenerated.
2002-09-04 23:25:15 +08:00
|
|
|
#include "base/levels.h"
|
2001-05-25 07:57:08 +08:00
|
|
|
|
2003-01-15 21:40:44 +08:00
|
|
|
#include "config/gimpbaseconfig.h"
|
|
|
|
|
|
|
|
#include "core/gimp.h"
|
2001-05-25 07:57:08 +08:00
|
|
|
#include "core/gimpdrawable.h"
|
|
|
|
#include "core/gimpdrawable-histogram.h"
|
|
|
|
#include "core/gimpimage.h"
|
2002-08-26 19:35:56 +08:00
|
|
|
#include "core/gimpimagemap.h"
|
2003-01-15 21:40:44 +08:00
|
|
|
#include "core/gimptoolinfo.h"
|
2001-05-25 07:57:08 +08:00
|
|
|
|
2002-03-18 00:35:05 +08:00
|
|
|
#include "widgets/gimpenummenu.h"
|
2001-05-25 07:57:08 +08:00
|
|
|
#include "widgets/gimphistogramview.h"
|
|
|
|
|
2001-09-26 07:23:09 +08:00
|
|
|
#include "display/gimpdisplay.h"
|
|
|
|
|
2001-05-25 07:57:08 +08:00
|
|
|
#include "gimplevelstool.h"
|
|
|
|
#include "tool_manager.h"
|
2000-12-17 05:37:03 +08:00
|
|
|
|
2003-03-26 00:38:19 +08:00
|
|
|
#include "gimp-intl.h"
|
1998-12-16 08:37:09 +08:00
|
|
|
|
2000-12-31 12:07:42 +08:00
|
|
|
|
2002-10-14 21:39:35 +08:00
|
|
|
#define LOW_INPUT (1 << 0)
|
|
|
|
#define GAMMA (1 << 1)
|
|
|
|
#define HIGH_INPUT (1 << 2)
|
|
|
|
#define LOW_OUTPUT (1 << 3)
|
|
|
|
#define HIGH_OUTPUT (1 << 4)
|
|
|
|
#define INPUT_LEVELS (1 << 5)
|
|
|
|
#define OUTPUT_LEVELS (1 << 6)
|
|
|
|
#define INPUT_SLIDERS (1 << 7)
|
|
|
|
#define OUTPUT_SLIDERS (1 << 8)
|
|
|
|
#define DRAW (1 << 9)
|
2003-03-17 01:00:40 +08:00
|
|
|
#define ALL_CHANNELS (1 << 10)
|
2002-10-14 21:39:35 +08:00
|
|
|
#define ALL 0xFFF
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-09-08 01:27:32 +08:00
|
|
|
#define DA_WIDTH GIMP_HISTOGRAM_VIEW_WIDTH
|
1997-11-25 06:05:25 +08:00
|
|
|
#define DA_HEIGHT 25
|
|
|
|
#define GRADIENT_HEIGHT 15
|
|
|
|
#define CONTROL_HEIGHT DA_HEIGHT - GRADIENT_HEIGHT
|
|
|
|
|
2002-10-14 21:39:35 +08:00
|
|
|
#define LEVELS_DA_MASK (GDK_EXPOSURE_MASK | \
|
|
|
|
GDK_ENTER_NOTIFY_MASK | \
|
|
|
|
GDK_BUTTON_PRESS_MASK | \
|
|
|
|
GDK_BUTTON_RELEASE_MASK | \
|
|
|
|
GDK_BUTTON1_MOTION_MASK | \
|
|
|
|
GDK_POINTER_MOTION_HINT_MASK)
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-12-31 12:07:42 +08:00
|
|
|
|
2001-05-25 07:57:08 +08:00
|
|
|
/* local function prototypes */
|
|
|
|
|
2003-03-15 23:02:36 +08:00
|
|
|
static void gimp_levels_tool_class_init (GimpLevelsToolClass *klass);
|
|
|
|
static void gimp_levels_tool_init (GimpLevelsTool *tool);
|
|
|
|
static void gimp_levels_tool_finalize (GObject *object);
|
|
|
|
|
|
|
|
static void gimp_levels_tool_initialize (GimpTool *tool,
|
|
|
|
GimpDisplay *gdisp);
|
|
|
|
static void gimp_levels_tool_button_press (GimpTool *tool,
|
|
|
|
GimpCoords *coords,
|
|
|
|
guint32 time,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpDisplay *gdisp);
|
|
|
|
static void gimp_levels_tool_motion (GimpTool *tool,
|
|
|
|
GimpCoords *coords,
|
|
|
|
guint32 time,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpDisplay *gdisp);
|
|
|
|
static void gimp_levels_tool_cursor_update (GimpTool *tool,
|
|
|
|
GimpCoords *coords,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpDisplay *gdisp);
|
2002-08-26 19:35:56 +08:00
|
|
|
|
|
|
|
static void gimp_levels_tool_map (GimpImageMapTool *image_map_tool);
|
|
|
|
static void gimp_levels_tool_dialog (GimpImageMapTool *image_map_tool);
|
|
|
|
static void gimp_levels_tool_reset (GimpImageMapTool *image_map_tool);
|
|
|
|
static void levels_update (GimpLevelsTool *l_tool,
|
|
|
|
gint update);
|
|
|
|
static void levels_channel_callback (GtkWidget *widget,
|
2002-12-18 23:57:25 +08:00
|
|
|
GimpLevelsTool *l_tool);
|
2002-08-26 19:35:56 +08:00
|
|
|
static void levels_channel_reset_callback (GtkWidget *widget,
|
2002-12-18 23:57:25 +08:00
|
|
|
GimpLevelsTool *l_tool);
|
2002-08-26 19:35:56 +08:00
|
|
|
static gboolean levels_set_sensitive_callback (gpointer item_data,
|
|
|
|
GimpLevelsTool *l_tool);
|
|
|
|
static void levels_auto_callback (GtkWidget *widget,
|
2002-12-18 23:57:25 +08:00
|
|
|
GimpLevelsTool *l_tool);
|
2002-08-26 19:35:56 +08:00
|
|
|
static void levels_load_callback (GtkWidget *widget,
|
2002-12-18 23:57:25 +08:00
|
|
|
GimpLevelsTool *l_tool);
|
2002-08-26 19:35:56 +08:00
|
|
|
static void levels_save_callback (GtkWidget *widget,
|
2002-12-18 23:57:25 +08:00
|
|
|
GimpLevelsTool *l_tool);
|
2002-08-26 19:35:56 +08:00
|
|
|
static void levels_low_input_adjustment_update (GtkAdjustment *adjustment,
|
2002-12-18 23:57:25 +08:00
|
|
|
GimpLevelsTool *l_tool);
|
2002-08-26 19:35:56 +08:00
|
|
|
static void levels_gamma_adjustment_update (GtkAdjustment *adjustment,
|
2002-12-18 23:57:25 +08:00
|
|
|
GimpLevelsTool *l_tool);
|
2002-08-26 19:35:56 +08:00
|
|
|
static void levels_high_input_adjustment_update (GtkAdjustment *adjustment,
|
2002-12-18 23:57:25 +08:00
|
|
|
GimpLevelsTool *l_tool);
|
2002-08-26 19:35:56 +08:00
|
|
|
static void levels_low_output_adjustment_update (GtkAdjustment *adjustment,
|
2002-12-18 23:57:25 +08:00
|
|
|
GimpLevelsTool *l_tool);
|
2002-08-26 19:35:56 +08:00
|
|
|
static void levels_high_output_adjustment_update (GtkAdjustment *adjustment,
|
2002-12-18 23:57:25 +08:00
|
|
|
GimpLevelsTool *l_tool);
|
2002-10-15 21:36:28 +08:00
|
|
|
static void levels_input_picker_toggled (GtkWidget *widget,
|
2002-12-18 23:57:25 +08:00
|
|
|
GimpLevelsTool *l_tool);
|
2002-08-26 19:35:56 +08:00
|
|
|
static gint levels_input_da_events (GtkWidget *widget,
|
|
|
|
GdkEvent *event,
|
|
|
|
GimpLevelsTool *l_tool);
|
|
|
|
static gint levels_output_da_events (GtkWidget *widget,
|
|
|
|
GdkEvent *event,
|
|
|
|
GimpLevelsTool *l_tool);
|
2003-03-15 23:02:36 +08:00
|
|
|
static void levels_input_color_pick (GimpTool *tool,
|
|
|
|
GimpDrawable *drawable,
|
|
|
|
GimpCoords *coords);
|
2002-08-26 19:35:56 +08:00
|
|
|
|
|
|
|
static void file_dialog_create (GimpLevelsTool *l_tool);
|
|
|
|
static void file_dialog_ok_callback (GimpLevelsTool *l_tool);
|
|
|
|
|
|
|
|
static gboolean levels_read_from_file (GimpLevelsTool *l_tool,
|
|
|
|
FILE *f);
|
|
|
|
static void levels_write_to_file (GimpLevelsTool *l_tool,
|
|
|
|
FILE *f);
|
|
|
|
|
2001-11-21 07:00:47 +08:00
|
|
|
|
|
|
|
static GimpImageMapToolClass *parent_class = NULL;
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-08-26 19:35:56 +08:00
|
|
|
/* public functions */
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-05-25 07:57:08 +08:00
|
|
|
void
|
2002-03-29 11:50:29 +08:00
|
|
|
gimp_levels_tool_register (GimpToolRegisterCallback callback,
|
2002-05-03 19:31:08 +08:00
|
|
|
gpointer data)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2002-03-29 11:50:29 +08:00
|
|
|
(* callback) (GIMP_TYPE_LEVELS_TOOL,
|
2003-02-05 22:39:40 +08:00
|
|
|
G_TYPE_NONE, NULL,
|
2001-11-21 07:00:47 +08:00
|
|
|
FALSE,
|
2002-03-21 20:17:17 +08:00
|
|
|
"gimp-levels-tool",
|
2001-11-21 07:00:47 +08:00
|
|
|
_("Levels"),
|
|
|
|
_("Adjust color levels"),
|
2001-12-04 01:59:48 +08:00
|
|
|
N_("/Layer/Colors/Levels..."), NULL,
|
2001-11-21 07:00:47 +08:00
|
|
|
NULL, "tools/levels.html",
|
2002-03-29 11:50:29 +08:00
|
|
|
GIMP_STOCK_TOOL_LEVELS,
|
2002-05-03 19:31:08 +08:00
|
|
|
data);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2001-08-14 22:53:55 +08:00
|
|
|
GType
|
2001-05-25 07:57:08 +08:00
|
|
|
gimp_levels_tool_get_type (void)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-08-14 22:53:55 +08:00
|
|
|
static GType tool_type = 0;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-05-25 07:57:08 +08:00
|
|
|
if (! tool_type)
|
1999-04-09 06:25:54 +08:00
|
|
|
{
|
2001-08-14 22:53:55 +08:00
|
|
|
static const GTypeInfo tool_info =
|
2001-05-25 07:57:08 +08:00
|
|
|
{
|
|
|
|
sizeof (GimpLevelsToolClass),
|
2001-08-14 22:53:55 +08:00
|
|
|
(GBaseInitFunc) NULL,
|
|
|
|
(GBaseFinalizeFunc) NULL,
|
|
|
|
(GClassInitFunc) gimp_levels_tool_class_init,
|
|
|
|
NULL, /* class_finalize */
|
|
|
|
NULL, /* class_data */
|
|
|
|
sizeof (GimpLevelsTool),
|
|
|
|
0, /* n_preallocs */
|
|
|
|
(GInstanceInitFunc) gimp_levels_tool_init,
|
2001-05-25 07:57:08 +08:00
|
|
|
};
|
|
|
|
|
2001-08-14 22:53:55 +08:00
|
|
|
tool_type = g_type_register_static (GIMP_TYPE_IMAGE_MAP_TOOL,
|
|
|
|
"GimpLevelsTool",
|
|
|
|
&tool_info, 0);
|
1999-04-09 06:25:54 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-05-25 07:57:08 +08:00
|
|
|
return tool_type;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-08-26 19:35:56 +08:00
|
|
|
|
|
|
|
/* private functions */
|
|
|
|
|
2001-05-25 07:57:08 +08:00
|
|
|
static void
|
|
|
|
gimp_levels_tool_class_init (GimpLevelsToolClass *klass)
|
|
|
|
{
|
2002-08-26 19:35:56 +08:00
|
|
|
GObjectClass *object_class;
|
|
|
|
GimpToolClass *tool_class;
|
|
|
|
GimpImageMapToolClass *image_map_tool_class;
|
1999-06-26 19:16:47 +08:00
|
|
|
|
2002-08-26 19:35:56 +08:00
|
|
|
object_class = G_OBJECT_CLASS (klass);
|
|
|
|
tool_class = GIMP_TOOL_CLASS (klass);
|
|
|
|
image_map_tool_class = GIMP_IMAGE_MAP_TOOL_CLASS (klass);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-08-14 22:53:55 +08:00
|
|
|
parent_class = g_type_class_peek_parent (klass);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-10-14 21:39:35 +08:00
|
|
|
object_class->finalize = gimp_levels_tool_finalize;
|
2002-08-26 19:35:56 +08:00
|
|
|
|
2002-10-15 21:36:28 +08:00
|
|
|
tool_class->initialize = gimp_levels_tool_initialize;
|
2003-03-15 23:02:36 +08:00
|
|
|
tool_class->button_press = gimp_levels_tool_button_press;
|
|
|
|
tool_class->motion = gimp_levels_tool_motion;
|
2002-10-15 21:36:28 +08:00
|
|
|
tool_class->cursor_update = gimp_levels_tool_cursor_update;
|
2002-08-26 19:35:56 +08:00
|
|
|
|
|
|
|
image_map_tool_class->map = gimp_levels_tool_map;
|
|
|
|
image_map_tool_class->dialog = gimp_levels_tool_dialog;
|
|
|
|
image_map_tool_class->reset = gimp_levels_tool_reset;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_levels_tool_init (GimpLevelsTool *l_tool)
|
|
|
|
{
|
|
|
|
GimpImageMapTool *image_map_tool;
|
|
|
|
|
|
|
|
image_map_tool = GIMP_IMAGE_MAP_TOOL (l_tool);
|
|
|
|
|
2002-10-14 21:39:35 +08:00
|
|
|
image_map_tool->shell_desc = _("Adjust Color Levels");
|
2002-08-26 19:35:56 +08:00
|
|
|
|
2002-10-15 21:36:28 +08:00
|
|
|
l_tool->lut = gimp_lut_new ();
|
|
|
|
l_tool->levels = g_new0 (Levels, 1);
|
2003-01-17 21:34:26 +08:00
|
|
|
l_tool->hist = NULL;
|
2002-10-15 21:36:28 +08:00
|
|
|
l_tool->channel = GIMP_HISTOGRAM_VALUE;
|
|
|
|
l_tool->active_picker = NULL;
|
More color correction stuff cleanup:
2002-09-04 Michael Natterer <mitch@gimp.org>
More color correction stuff cleanup:
* app/base/Makefile.am
* app/base/base-types.h
* app/base/levels.[ch]: new files containing levels_lut_func(), a
new "Levels" parameter struct and the "auto levels" stuff.
* app/base/lut-funcs.[ch]: removed the levels stuff here, added
lots of g_return_if_fail().
* app/base/color-balance.[ch]
* app/base/hue-saturation.[ch]: added init() and reset() functions
so we don't need to duplicate this code in the tool and the pdb
wrappers.
* app/base/curves.[ch]: s/gint/GimpHistogramChannel/g, made
curves_channel_reset() initialize the curves array.
* app/tools/gimpcolorbalancetool.[ch]: use the new functions,
moved the "Range" frame to the top, added a per-range "Reset"
button, made the global "Reset" button reset all ranges and
the "Preserve Luminosity" toggle.
* app/tools/gimpcurvestool.[ch]: don't initialize the curves
array manually, as curves_channel_reset() does that,
s/gint/GimpHistogramChannel/g.
* app/tools/gimphuesaturationtool.c: use the new functions, added
a per-channel "Reset" button and made the global "Reset" button
reset all channels, cleaned up the GUI update function.
* app/tools/gimplevelstool.[ch]: changed to use the new Levels
parameter struct and it's utility functions. Removed stuff
which now lives in base/levels.c
* app/tools/gimpimagemaptool.c: align the "Preview" button
bottom-left, not bottom-right.
* tools/pdbgen/pdb/color.pdb: use the new stuff and removed
uglyness because using the "Levels" struct makes the code more
straightforward.
* app/pdb/color_cmds.c: regenerated.
2002-09-04 23:25:15 +08:00
|
|
|
|
|
|
|
levels_init (l_tool->levels);
|
2000-09-29 09:22:27 +08:00
|
|
|
}
|
|
|
|
|
2001-05-25 07:57:08 +08:00
|
|
|
static void
|
2002-08-26 19:35:56 +08:00
|
|
|
gimp_levels_tool_finalize (GObject *object)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2002-08-26 19:35:56 +08:00
|
|
|
GimpLevelsTool *l_tool;
|
|
|
|
|
|
|
|
l_tool = GIMP_LEVELS_TOOL (object);
|
|
|
|
|
|
|
|
if (l_tool->lut)
|
|
|
|
{
|
|
|
|
gimp_lut_free (l_tool->lut);
|
|
|
|
l_tool->lut = NULL;
|
|
|
|
}
|
|
|
|
|
More color correction stuff cleanup:
2002-09-04 Michael Natterer <mitch@gimp.org>
More color correction stuff cleanup:
* app/base/Makefile.am
* app/base/base-types.h
* app/base/levels.[ch]: new files containing levels_lut_func(), a
new "Levels" parameter struct and the "auto levels" stuff.
* app/base/lut-funcs.[ch]: removed the levels stuff here, added
lots of g_return_if_fail().
* app/base/color-balance.[ch]
* app/base/hue-saturation.[ch]: added init() and reset() functions
so we don't need to duplicate this code in the tool and the pdb
wrappers.
* app/base/curves.[ch]: s/gint/GimpHistogramChannel/g, made
curves_channel_reset() initialize the curves array.
* app/tools/gimpcolorbalancetool.[ch]: use the new functions,
moved the "Range" frame to the top, added a per-range "Reset"
button, made the global "Reset" button reset all ranges and
the "Preserve Luminosity" toggle.
* app/tools/gimpcurvestool.[ch]: don't initialize the curves
array manually, as curves_channel_reset() does that,
s/gint/GimpHistogramChannel/g.
* app/tools/gimphuesaturationtool.c: use the new functions, added
a per-channel "Reset" button and made the global "Reset" button
reset all channels, cleaned up the GUI update function.
* app/tools/gimplevelstool.[ch]: changed to use the new Levels
parameter struct and it's utility functions. Removed stuff
which now lives in base/levels.c
* app/tools/gimpimagemaptool.c: align the "Preview" button
bottom-left, not bottom-right.
* tools/pdbgen/pdb/color.pdb: use the new stuff and removed
uglyness because using the "Levels" struct makes the code more
straightforward.
* app/pdb/color_cmds.c: regenerated.
2002-09-04 23:25:15 +08:00
|
|
|
if (l_tool->levels)
|
|
|
|
{
|
|
|
|
g_free (l_tool->levels);
|
|
|
|
l_tool->levels = NULL;
|
|
|
|
}
|
|
|
|
|
2002-08-26 19:35:56 +08:00
|
|
|
if (l_tool->hist)
|
|
|
|
{
|
|
|
|
gimp_histogram_free (l_tool->hist);
|
|
|
|
l_tool->hist = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
2001-05-25 07:57:08 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2001-10-29 19:47:11 +08:00
|
|
|
gimp_levels_tool_initialize (GimpTool *tool,
|
|
|
|
GimpDisplay *gdisp)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2002-08-26 19:35:56 +08:00
|
|
|
GimpLevelsTool *l_tool;
|
|
|
|
GimpDrawable *drawable;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-08-26 19:35:56 +08:00
|
|
|
l_tool = GIMP_LEVELS_TOOL (tool);
|
2001-05-25 07:57:08 +08:00
|
|
|
|
2003-02-04 07:54:19 +08:00
|
|
|
drawable = gimp_image_active_drawable (gdisp->gimage);
|
|
|
|
|
|
|
|
if (gimp_drawable_is_indexed (drawable))
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1998-12-16 08:37:09 +08:00
|
|
|
g_message (_("Levels for indexed drawables cannot be adjusted."));
|
1997-11-25 06:05:25 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2003-01-17 21:34:26 +08:00
|
|
|
if (!l_tool->hist)
|
|
|
|
{
|
|
|
|
Gimp *gimp = GIMP_TOOL (l_tool)->tool_info->gimp;
|
|
|
|
|
|
|
|
l_tool->hist = gimp_histogram_new (GIMP_BASE_CONFIG (gimp->config));
|
|
|
|
}
|
|
|
|
|
More color correction stuff cleanup:
2002-09-04 Michael Natterer <mitch@gimp.org>
More color correction stuff cleanup:
* app/base/Makefile.am
* app/base/base-types.h
* app/base/levels.[ch]: new files containing levels_lut_func(), a
new "Levels" parameter struct and the "auto levels" stuff.
* app/base/lut-funcs.[ch]: removed the levels stuff here, added
lots of g_return_if_fail().
* app/base/color-balance.[ch]
* app/base/hue-saturation.[ch]: added init() and reset() functions
so we don't need to duplicate this code in the tool and the pdb
wrappers.
* app/base/curves.[ch]: s/gint/GimpHistogramChannel/g, made
curves_channel_reset() initialize the curves array.
* app/tools/gimpcolorbalancetool.[ch]: use the new functions,
moved the "Range" frame to the top, added a per-range "Reset"
button, made the global "Reset" button reset all ranges and
the "Preserve Luminosity" toggle.
* app/tools/gimpcurvestool.[ch]: don't initialize the curves
array manually, as curves_channel_reset() does that,
s/gint/GimpHistogramChannel/g.
* app/tools/gimphuesaturationtool.c: use the new functions, added
a per-channel "Reset" button and made the global "Reset" button
reset all channels, cleaned up the GUI update function.
* app/tools/gimplevelstool.[ch]: changed to use the new Levels
parameter struct and it's utility functions. Removed stuff
which now lives in base/levels.c
* app/tools/gimpimagemaptool.c: align the "Preview" button
bottom-left, not bottom-right.
* tools/pdbgen/pdb/color.pdb: use the new stuff and removed
uglyness because using the "Levels" struct makes the code more
straightforward.
* app/pdb/color_cmds.c: regenerated.
2002-09-04 23:25:15 +08:00
|
|
|
levels_init (l_tool->levels);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-08-26 19:35:56 +08:00
|
|
|
l_tool->channel = GIMP_HISTOGRAM_VALUE;
|
|
|
|
l_tool->color = gimp_drawable_is_rgb (drawable);
|
|
|
|
|
2003-03-17 01:00:40 +08:00
|
|
|
if (l_tool->active_picker)
|
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (l_tool->active_picker),
|
|
|
|
FALSE);
|
|
|
|
|
2002-08-26 19:35:56 +08:00
|
|
|
GIMP_TOOL_CLASS (parent_class)->initialize (tool, gdisp);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-03-18 00:35:05 +08:00
|
|
|
/* set the sensitivity of the channel menu based on the drawable type */
|
2002-08-26 19:35:56 +08:00
|
|
|
gimp_option_menu_set_sensitive (GTK_OPTION_MENU (l_tool->channel_menu),
|
2002-03-18 00:35:05 +08:00
|
|
|
(GimpOptionMenuSensitivityCallback) levels_set_sensitive_callback,
|
2002-08-26 19:35:56 +08:00
|
|
|
l_tool);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* set the current selection */
|
2002-08-26 19:35:56 +08:00
|
|
|
gtk_option_menu_set_history (GTK_OPTION_MENU (l_tool->channel_menu),
|
|
|
|
l_tool->channel);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-08-26 19:35:56 +08:00
|
|
|
levels_update (l_tool, (LOW_INPUT | GAMMA | HIGH_INPUT |
|
|
|
|
LOW_OUTPUT | HIGH_OUTPUT |
|
|
|
|
DRAW | INPUT_LEVELS | OUTPUT_LEVELS));
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-08-26 19:35:56 +08:00
|
|
|
gimp_drawable_calculate_histogram (drawable, l_tool->hist);
|
2002-10-15 09:15:43 +08:00
|
|
|
gimp_histogram_view_set_histogram (GIMP_HISTOGRAM_VIEW (l_tool->hist_view),
|
|
|
|
l_tool->hist);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2003-03-15 23:02:36 +08:00
|
|
|
static void
|
|
|
|
gimp_levels_tool_button_press (GimpTool *tool,
|
|
|
|
GimpCoords *coords,
|
|
|
|
guint32 time,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpDisplay *gdisp)
|
|
|
|
{
|
|
|
|
levels_input_color_pick (tool, tool->drawable, coords);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_levels_tool_motion (GimpTool *tool,
|
|
|
|
GimpCoords *coords,
|
|
|
|
guint32 time,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpDisplay *gdisp)
|
|
|
|
{
|
|
|
|
levels_input_color_pick (tool, tool->drawable, coords);
|
|
|
|
}
|
|
|
|
|
2002-10-15 21:36:28 +08:00
|
|
|
static void
|
|
|
|
gimp_levels_tool_cursor_update (GimpTool *tool,
|
|
|
|
GimpCoords *coords,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpDisplay *gdisp)
|
|
|
|
{
|
|
|
|
if (GIMP_LEVELS_TOOL (tool)->active_picker)
|
|
|
|
{
|
2003-03-15 23:02:36 +08:00
|
|
|
gimp_tool_control_set_tool_cursor (tool->control,
|
|
|
|
GIMP_COLOR_PICKER_TOOL_CURSOR);
|
2002-10-15 21:36:28 +08:00
|
|
|
gimp_tool_control_set_cursor (tool->control,
|
|
|
|
gimp_display_coords_in_active_drawable (gdisp,
|
|
|
|
coords) ?
|
|
|
|
GIMP_MOUSE_CURSOR : GIMP_BAD_CURSOR);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gimp_tool_control_set_tool_cursor (tool->control, GIMP_TOOL_CURSOR_NONE);
|
|
|
|
gimp_tool_control_set_cursor (tool->control, GIMP_MOUSE_CURSOR);
|
|
|
|
}
|
|
|
|
|
|
|
|
GIMP_TOOL_CLASS (parent_class)->cursor_update (tool, coords, state, gdisp);
|
|
|
|
}
|
|
|
|
|
2001-05-25 07:57:08 +08:00
|
|
|
static void
|
2002-08-26 19:35:56 +08:00
|
|
|
gimp_levels_tool_map (GimpImageMapTool *image_map_tool)
|
2001-05-25 07:57:08 +08:00
|
|
|
{
|
2002-08-26 19:35:56 +08:00
|
|
|
GimpLevelsTool *l_tool;
|
2001-05-25 07:57:08 +08:00
|
|
|
|
2002-08-26 19:35:56 +08:00
|
|
|
l_tool = GIMP_LEVELS_TOOL (image_map_tool);
|
2001-05-25 07:57:08 +08:00
|
|
|
|
2002-08-26 19:35:56 +08:00
|
|
|
gimp_image_map_apply (image_map_tool->image_map,
|
|
|
|
(GimpImageMapApplyFunc) gimp_lut_process_2,
|
|
|
|
l_tool->lut);
|
2001-05-25 07:57:08 +08:00
|
|
|
}
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-06-23 23:24:46 +08:00
|
|
|
/*******************/
|
|
|
|
/* Levels dialog */
|
|
|
|
/*******************/
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-03-17 01:00:40 +08:00
|
|
|
|
|
|
|
static GtkWidget *
|
|
|
|
gimp_levels_tool_color_picker_new (GimpLevelsTool *tool,
|
|
|
|
guint value)
|
|
|
|
{
|
|
|
|
GtkWidget *button;
|
|
|
|
const gchar *stock_id;
|
|
|
|
const gchar *help;
|
|
|
|
|
|
|
|
switch (value & 0xF)
|
|
|
|
{
|
|
|
|
case LOW_INPUT:
|
|
|
|
stock_id = GIMP_STOCK_COLOR_PICKER_BLACK;
|
|
|
|
help = _("Pick Black Point");
|
|
|
|
break;
|
|
|
|
case GAMMA:
|
|
|
|
stock_id = GIMP_STOCK_COLOR_PICKER_GRAY;
|
|
|
|
help = _("Pick Gray Point");
|
|
|
|
break;
|
|
|
|
case HIGH_INPUT:
|
|
|
|
stock_id = GIMP_STOCK_COLOR_PICKER_WHITE;
|
|
|
|
help = _("Pick White Point");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
button = g_object_new (GTK_TYPE_TOGGLE_BUTTON,
|
|
|
|
"label", stock_id,
|
|
|
|
"use_stock", TRUE,
|
|
|
|
"draw_indicator", FALSE,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
gimp_help_set_help_data (button, help, NULL);
|
|
|
|
|
|
|
|
g_object_set_data (G_OBJECT (button), "pick_value", GUINT_TO_POINTER (value));
|
|
|
|
g_signal_connect (button, "toggled",
|
|
|
|
G_CALLBACK (levels_input_picker_toggled),
|
|
|
|
tool);
|
|
|
|
|
|
|
|
return button;
|
|
|
|
}
|
|
|
|
|
2002-08-26 19:35:56 +08:00
|
|
|
static void
|
|
|
|
gimp_levels_tool_dialog (GimpImageMapTool *image_map_tool)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2002-08-26 19:35:56 +08:00
|
|
|
GimpLevelsTool *l_tool;
|
|
|
|
GtkWidget *vbox;
|
|
|
|
GtkWidget *vbox2;
|
|
|
|
GtkWidget *vbox3;
|
|
|
|
GtkWidget *hbox;
|
2002-10-14 01:24:29 +08:00
|
|
|
GtkWidget *hbox2;
|
2002-08-26 19:35:56 +08:00
|
|
|
GtkWidget *label;
|
2003-03-25 02:04:11 +08:00
|
|
|
GtkWidget *menu;
|
2002-08-26 19:35:56 +08:00
|
|
|
GtkWidget *frame;
|
|
|
|
GtkWidget *channel_hbox;
|
|
|
|
GtkWidget *hbbox;
|
|
|
|
GtkWidget *button;
|
|
|
|
GtkWidget *spinbutton;
|
|
|
|
GtkObject *data;
|
|
|
|
|
|
|
|
l_tool = GIMP_LEVELS_TOOL (image_map_tool);
|
1999-11-22 19:14:29 +08:00
|
|
|
|
|
|
|
hbox = gtk_hbox_new (TRUE, 0);
|
2002-08-26 19:35:56 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (image_map_tool->main_vbox), hbox,
|
|
|
|
FALSE, FALSE, 0);
|
1999-11-22 19:14:29 +08:00
|
|
|
gtk_widget_show (hbox);
|
|
|
|
|
|
|
|
vbox = gtk_vbox_new (FALSE, 4);
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), vbox, FALSE, FALSE, 0);
|
2002-08-26 19:35:56 +08:00
|
|
|
gtk_widget_show (vbox);
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* The option menu for selecting channels */
|
1999-11-22 19:14:29 +08:00
|
|
|
channel_hbox = gtk_hbox_new (FALSE, 4);
|
1997-11-25 06:05:25 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), channel_hbox, FALSE, FALSE, 0);
|
2002-08-26 19:35:56 +08:00
|
|
|
gtk_widget_show (channel_hbox);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-11-22 19:14:29 +08:00
|
|
|
label = gtk_label_new (_("Modify Levels for Channel:"));
|
1997-11-25 06:05:25 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (channel_hbox), label, FALSE, FALSE, 0);
|
2000-02-14 06:26:41 +08:00
|
|
|
gtk_widget_show (label);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-03-25 02:04:11 +08:00
|
|
|
menu = gimp_enum_option_menu_new (GIMP_TYPE_HISTOGRAM_CHANNEL,
|
|
|
|
G_CALLBACK (levels_channel_callback),
|
|
|
|
l_tool);
|
|
|
|
gimp_enum_option_menu_set_stock_prefix (GTK_OPTION_MENU (menu),
|
|
|
|
"gimp-channel");
|
|
|
|
gtk_box_pack_start (GTK_BOX (channel_hbox), menu, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (menu);
|
|
|
|
|
|
|
|
l_tool->channel_menu = menu;
|
1999-11-22 19:14:29 +08:00
|
|
|
|
More color correction stuff cleanup:
2002-09-04 Michael Natterer <mitch@gimp.org>
More color correction stuff cleanup:
* app/base/Makefile.am
* app/base/base-types.h
* app/base/levels.[ch]: new files containing levels_lut_func(), a
new "Levels" parameter struct and the "auto levels" stuff.
* app/base/lut-funcs.[ch]: removed the levels stuff here, added
lots of g_return_if_fail().
* app/base/color-balance.[ch]
* app/base/hue-saturation.[ch]: added init() and reset() functions
so we don't need to duplicate this code in the tool and the pdb
wrappers.
* app/base/curves.[ch]: s/gint/GimpHistogramChannel/g, made
curves_channel_reset() initialize the curves array.
* app/tools/gimpcolorbalancetool.[ch]: use the new functions,
moved the "Range" frame to the top, added a per-range "Reset"
button, made the global "Reset" button reset all ranges and
the "Preserve Luminosity" toggle.
* app/tools/gimpcurvestool.[ch]: don't initialize the curves
array manually, as curves_channel_reset() does that,
s/gint/GimpHistogramChannel/g.
* app/tools/gimphuesaturationtool.c: use the new functions, added
a per-channel "Reset" button and made the global "Reset" button
reset all channels, cleaned up the GUI update function.
* app/tools/gimplevelstool.[ch]: changed to use the new Levels
parameter struct and it's utility functions. Removed stuff
which now lives in base/levels.c
* app/tools/gimpimagemaptool.c: align the "Preview" button
bottom-left, not bottom-right.
* tools/pdbgen/pdb/color.pdb: use the new stuff and removed
uglyness because using the "Levels" struct makes the code more
straightforward.
* app/pdb/color_cmds.c: regenerated.
2002-09-04 23:25:15 +08:00
|
|
|
button = gtk_button_new_with_mnemonic (_("R_eset Channel"));
|
2002-08-26 19:35:56 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (channel_hbox), button, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (button);
|
added gimphistogram*, histogramwidget*, removed histogram.[ch]
* app/Makefile.am: added gimphistogram*, histogramwidget*,
removed histogram.[ch]
* app/histogram.[ch]: removed. replaced with histogramwidget.[ch].
* app/{gimphistogramP.h, gimphistogram.h, gimphistogram.c}: new
functions that calculate histograms in parallel and perform
calculations on them.
* app/histogramwidget.[ch]: Same as old histogram.[ch], only it is
now a real widget, and it uses GimpHistograms instead of arrays of
values.
* app/curves.c: #include gimphistogram.h instead of histogram.h.
* app/equalize.c: use GimpHistogram and GimpLut.
* app/gimpbrush.c, app/gimpimage.c, app/gimpset.c: use
GTK_RUN_FIRST in calls to gimp_signal_new.
* app/histogram_tool.c, app/levels.c, app/threshold.c: modified to
use the new HistogramWidget.
* app/paint_funcs.c: removed some unused variables.
* app/preferences_dialog.c: only display the num-processor field
if we are configured --with-mp
* plug-ins/gee/gee.c: removed a couple of c++ style comments.
1999-03-01 13:11:19 +08:00
|
|
|
|
2003-01-06 06:07:10 +08:00
|
|
|
g_signal_connect (button, "clicked",
|
2002-08-26 19:35:56 +08:00
|
|
|
G_CALLBACK (levels_channel_reset_callback),
|
|
|
|
l_tool);
|
1999-11-22 19:14:29 +08:00
|
|
|
|
|
|
|
|
2002-08-26 19:35:56 +08:00
|
|
|
/* Input levels frame */
|
|
|
|
frame = gtk_frame_new (_("Input Levels"));
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (frame);
|
1999-11-22 19:14:29 +08:00
|
|
|
|
2002-08-29 03:47:07 +08:00
|
|
|
hbox = gtk_hbox_new (TRUE, 2);
|
|
|
|
gtk_container_add (GTK_CONTAINER (frame), hbox);
|
|
|
|
gtk_widget_show (hbox);
|
|
|
|
|
2002-08-26 19:35:56 +08:00
|
|
|
vbox2 = gtk_vbox_new (FALSE, 4);
|
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (vbox2), 2);
|
2002-08-29 03:47:07 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), vbox2, TRUE, FALSE, 0);
|
2002-08-26 19:35:56 +08:00
|
|
|
gtk_widget_show (vbox2);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
frame = gtk_frame_new (NULL);
|
2002-08-26 19:35:56 +08:00
|
|
|
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
|
2002-08-29 03:47:07 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox2), frame, FALSE, FALSE, 0);
|
2002-08-26 19:35:56 +08:00
|
|
|
gtk_widget_show (frame);
|
|
|
|
|
2002-10-15 09:15:43 +08:00
|
|
|
l_tool->hist_view = gimp_histogram_view_new (GIMP_HISTOGRAM_VIEW_WIDTH,
|
|
|
|
GIMP_HISTOGRAM_VIEW_HEIGHT,
|
|
|
|
FALSE);
|
|
|
|
gtk_container_add (GTK_CONTAINER (frame), l_tool->hist_view);
|
|
|
|
gtk_widget_show (GTK_WIDGET (l_tool->hist_view));
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* The input levels drawing area */
|
|
|
|
hbox = gtk_hbox_new (TRUE, 2);
|
2002-08-26 19:35:56 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox2), hbox, TRUE, FALSE, 0);
|
|
|
|
gtk_widget_show (hbox);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
frame = gtk_frame_new (NULL);
|
2002-08-26 19:35:56 +08:00
|
|
|
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
|
1997-11-25 06:05:25 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), frame, FALSE, FALSE, 0);
|
2002-08-26 19:35:56 +08:00
|
|
|
gtk_widget_show (frame);
|
1999-11-22 19:14:29 +08:00
|
|
|
|
2002-08-26 19:35:56 +08:00
|
|
|
vbox3 = gtk_vbox_new (FALSE, 2);
|
|
|
|
gtk_container_add (GTK_CONTAINER (frame), vbox3);
|
|
|
|
gtk_widget_show (vbox3);
|
1999-11-22 19:14:29 +08:00
|
|
|
|
2002-08-26 19:35:56 +08:00
|
|
|
l_tool->input_levels_da[0] = gtk_preview_new (GTK_PREVIEW_COLOR);
|
|
|
|
gtk_preview_size (GTK_PREVIEW (l_tool->input_levels_da[0]),
|
1999-11-22 19:14:29 +08:00
|
|
|
DA_WIDTH, GRADIENT_HEIGHT);
|
2002-08-26 19:35:56 +08:00
|
|
|
gtk_widget_set_events (l_tool->input_levels_da[0], LEVELS_DA_MASK);
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox3), l_tool->input_levels_da[0],
|
|
|
|
FALSE, TRUE, 0);
|
|
|
|
gtk_widget_show (l_tool->input_levels_da[0]);
|
1999-11-22 19:14:29 +08:00
|
|
|
|
2003-01-06 06:07:10 +08:00
|
|
|
g_signal_connect (l_tool->input_levels_da[0], "event",
|
2001-08-01 10:57:58 +08:00
|
|
|
G_CALLBACK (levels_input_da_events),
|
2002-08-26 19:35:56 +08:00
|
|
|
l_tool);
|
1999-11-22 19:14:29 +08:00
|
|
|
|
2002-08-26 19:35:56 +08:00
|
|
|
l_tool->input_levels_da[1] = gtk_drawing_area_new ();
|
|
|
|
gtk_widget_set_size_request (l_tool->input_levels_da[1],
|
2001-12-29 21:26:29 +08:00
|
|
|
DA_WIDTH, CONTROL_HEIGHT);
|
2002-08-26 19:35:56 +08:00
|
|
|
gtk_widget_set_events (l_tool->input_levels_da[1], LEVELS_DA_MASK);
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox3), l_tool->input_levels_da[1],
|
|
|
|
FALSE, TRUE, 0);
|
|
|
|
gtk_widget_show (l_tool->input_levels_da[1]);
|
1999-11-22 19:14:29 +08:00
|
|
|
|
2003-01-06 06:07:10 +08:00
|
|
|
g_signal_connect (l_tool->input_levels_da[1], "event",
|
2001-08-01 10:57:58 +08:00
|
|
|
G_CALLBACK (levels_input_da_events),
|
2002-08-26 19:35:56 +08:00
|
|
|
l_tool);
|
1999-11-22 19:14:29 +08:00
|
|
|
|
2002-08-26 19:35:56 +08:00
|
|
|
/* Horizontal box for input levels spinbuttons */
|
1999-11-22 19:14:29 +08:00
|
|
|
hbox = gtk_hbox_new (FALSE, 4);
|
2002-08-26 19:35:56 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox2), hbox, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (hbox);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-08-26 19:35:56 +08:00
|
|
|
/* low input spin */
|
2002-10-14 01:24:29 +08:00
|
|
|
hbox2 = gtk_hbox_new (FALSE, 0);
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), hbox2, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (hbox2);
|
|
|
|
|
2003-03-17 01:00:40 +08:00
|
|
|
button = gimp_levels_tool_color_picker_new (l_tool, LOW_INPUT);
|
2002-10-14 01:24:29 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (hbox2), button, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (button);
|
|
|
|
|
1999-11-22 19:14:29 +08:00
|
|
|
data = gtk_adjustment_new (0, 0, 255, 1, 10, 10);
|
2002-08-26 19:35:56 +08:00
|
|
|
l_tool->low_input_data = GTK_ADJUSTMENT (data);
|
1999-11-22 19:14:29 +08:00
|
|
|
|
2002-08-26 19:35:56 +08:00
|
|
|
spinbutton = gtk_spin_button_new (l_tool->low_input_data, 0.5, 0);
|
1999-11-22 19:14:29 +08:00
|
|
|
gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbutton), TRUE);
|
2002-10-14 01:24:29 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (hbox2), spinbutton, FALSE, FALSE, 0);
|
2002-08-26 19:35:56 +08:00
|
|
|
gtk_widget_show (spinbutton);
|
1999-04-13 12:59:07 +08:00
|
|
|
|
2003-01-06 06:07:10 +08:00
|
|
|
g_signal_connect (l_tool->low_input_data, "value_changed",
|
2002-08-26 19:35:56 +08:00
|
|
|
G_CALLBACK (levels_low_input_adjustment_update),
|
|
|
|
l_tool);
|
|
|
|
|
|
|
|
/* input gamma spin */
|
2002-10-14 01:24:29 +08:00
|
|
|
hbox2 = gtk_hbox_new (FALSE, 0);
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), hbox2, TRUE, FALSE, 0);
|
|
|
|
gtk_widget_show (hbox2);
|
|
|
|
|
2003-03-17 01:00:40 +08:00
|
|
|
button = gimp_levels_tool_color_picker_new (l_tool, GAMMA);
|
2002-10-14 01:24:29 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (hbox2), button, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (button);
|
|
|
|
|
2002-08-26 19:35:56 +08:00
|
|
|
data = gtk_adjustment_new (1, 0.1, 10, 0.1, 1, 1);
|
|
|
|
l_tool->gamma_data = GTK_ADJUSTMENT (data);
|
1999-11-22 19:14:29 +08:00
|
|
|
|
2002-08-26 19:35:56 +08:00
|
|
|
spinbutton = gtk_spin_button_new (l_tool->gamma_data, 0.5, 2);
|
|
|
|
gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbutton), TRUE);
|
2002-10-14 01:24:29 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (hbox2), spinbutton, FALSE, FALSE, 0);
|
2002-08-26 19:35:56 +08:00
|
|
|
gimp_help_set_help_data (spinbutton, _("Gamma"), NULL);
|
1999-11-22 19:14:29 +08:00
|
|
|
gtk_widget_show (spinbutton);
|
1999-04-13 12:59:07 +08:00
|
|
|
|
2003-01-06 06:07:10 +08:00
|
|
|
g_signal_connect (l_tool->gamma_data, "value_changed",
|
2002-08-26 19:35:56 +08:00
|
|
|
G_CALLBACK (levels_gamma_adjustment_update),
|
|
|
|
l_tool);
|
|
|
|
|
|
|
|
/* high input spin */
|
2002-10-14 01:24:29 +08:00
|
|
|
hbox2 = gtk_hbox_new (FALSE, 0);
|
|
|
|
gtk_box_pack_end (GTK_BOX (hbox), hbox2, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (hbox2);
|
|
|
|
|
2003-03-17 01:00:40 +08:00
|
|
|
button = gimp_levels_tool_color_picker_new (l_tool, HIGH_INPUT);
|
2002-10-14 01:24:29 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (hbox2), button, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (button);
|
|
|
|
|
1999-11-22 19:14:29 +08:00
|
|
|
data = gtk_adjustment_new (255, 0, 255, 1, 10, 10);
|
2002-08-26 19:35:56 +08:00
|
|
|
l_tool->high_input_data = GTK_ADJUSTMENT (data);
|
1999-11-22 19:14:29 +08:00
|
|
|
|
2002-08-26 19:35:56 +08:00
|
|
|
spinbutton = gtk_spin_button_new (l_tool->high_input_data, 0.5, 0);
|
1999-11-22 19:14:29 +08:00
|
|
|
gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbutton), TRUE);
|
2002-10-14 01:24:29 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (hbox2), spinbutton, FALSE, FALSE, 0);
|
2002-08-26 19:35:56 +08:00
|
|
|
gtk_widget_show (spinbutton);
|
1999-04-13 12:59:07 +08:00
|
|
|
|
2003-01-06 06:07:10 +08:00
|
|
|
g_signal_connect (l_tool->high_input_data, "value_changed",
|
2002-08-26 19:35:56 +08:00
|
|
|
G_CALLBACK (levels_high_input_adjustment_update),
|
|
|
|
l_tool);
|
1999-11-22 19:14:29 +08:00
|
|
|
|
2002-08-26 19:35:56 +08:00
|
|
|
|
|
|
|
/* Output levels frame */
|
|
|
|
frame = gtk_frame_new (_("Output Levels"));
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (frame);
|
|
|
|
|
2002-08-29 03:47:07 +08:00
|
|
|
hbox = gtk_hbox_new (TRUE, 2);
|
|
|
|
gtk_container_add (GTK_CONTAINER (frame), hbox);
|
|
|
|
gtk_widget_show (hbox);
|
|
|
|
|
2002-08-26 19:35:56 +08:00
|
|
|
vbox2 = gtk_vbox_new (FALSE, 4);
|
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (vbox2), 2);
|
2002-08-29 03:47:07 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), vbox2, TRUE, FALSE, 0);
|
2002-08-26 19:35:56 +08:00
|
|
|
gtk_widget_show (vbox2);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
frame = gtk_frame_new (NULL);
|
2002-08-26 19:35:56 +08:00
|
|
|
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
|
2002-08-29 03:47:07 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox2), frame, FALSE, FALSE, 0);
|
2002-08-26 19:35:56 +08:00
|
|
|
gtk_widget_show (frame);
|
1999-11-22 19:14:29 +08:00
|
|
|
|
2002-08-26 19:35:56 +08:00
|
|
|
vbox3 = gtk_vbox_new (FALSE, 2);
|
|
|
|
gtk_container_add (GTK_CONTAINER (frame), vbox3);
|
|
|
|
gtk_widget_show (vbox3);
|
1999-11-22 19:14:29 +08:00
|
|
|
|
2002-08-26 19:35:56 +08:00
|
|
|
l_tool->output_levels_da[0] = gtk_preview_new (GTK_PREVIEW_COLOR);
|
|
|
|
gtk_preview_size (GTK_PREVIEW (l_tool->output_levels_da[0]),
|
|
|
|
DA_WIDTH, GRADIENT_HEIGHT);
|
|
|
|
gtk_widget_set_events (l_tool->output_levels_da[0], LEVELS_DA_MASK);
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox3), l_tool->output_levels_da[0],
|
|
|
|
FALSE, TRUE, 0);
|
|
|
|
gtk_widget_show (l_tool->output_levels_da[0]);
|
1999-11-22 19:14:29 +08:00
|
|
|
|
2003-01-06 06:07:10 +08:00
|
|
|
g_signal_connect (l_tool->output_levels_da[0], "event",
|
2001-08-01 10:57:58 +08:00
|
|
|
G_CALLBACK (levels_output_da_events),
|
2002-08-26 19:35:56 +08:00
|
|
|
l_tool);
|
1999-11-22 19:14:29 +08:00
|
|
|
|
2002-08-26 19:35:56 +08:00
|
|
|
l_tool->output_levels_da[1] = gtk_preview_new (GTK_PREVIEW_GRAYSCALE);
|
|
|
|
gtk_preview_size (GTK_PREVIEW (l_tool->output_levels_da[1]),
|
|
|
|
DA_WIDTH, CONTROL_HEIGHT);
|
|
|
|
gtk_widget_set_events (l_tool->output_levels_da[1], LEVELS_DA_MASK);
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox3), l_tool->output_levels_da[1],
|
|
|
|
FALSE, TRUE, 0);
|
|
|
|
gtk_widget_show (l_tool->output_levels_da[1]);
|
1999-11-22 19:14:29 +08:00
|
|
|
|
2003-01-06 06:07:10 +08:00
|
|
|
g_signal_connect (l_tool->output_levels_da[1], "event",
|
2001-08-01 10:57:58 +08:00
|
|
|
G_CALLBACK (levels_output_da_events),
|
2002-08-26 19:35:56 +08:00
|
|
|
l_tool);
|
1999-11-22 19:14:29 +08:00
|
|
|
|
2002-08-26 19:35:56 +08:00
|
|
|
/* Horizontal box for levels spin widgets */
|
|
|
|
hbox = gtk_hbox_new (FALSE, 4);
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox2), hbox, FALSE, FALSE, 0);
|
1997-11-25 06:05:25 +08:00
|
|
|
gtk_widget_show (hbox);
|
|
|
|
|
2002-08-26 19:35:56 +08:00
|
|
|
/* low output spin */
|
|
|
|
data = gtk_adjustment_new (0, 0, 255, 1, 10, 10);
|
|
|
|
l_tool->low_output_data = GTK_ADJUSTMENT (data);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-08-26 19:35:56 +08:00
|
|
|
spinbutton = gtk_spin_button_new (l_tool->low_output_data, 0.5, 0);
|
|
|
|
gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbutton), TRUE);
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), spinbutton, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (spinbutton);
|
1999-11-22 19:14:29 +08:00
|
|
|
|
2003-01-06 06:07:10 +08:00
|
|
|
g_signal_connect (l_tool->low_output_data, "value_changed",
|
2002-08-26 19:35:56 +08:00
|
|
|
G_CALLBACK (levels_low_output_adjustment_update),
|
|
|
|
l_tool);
|
1999-11-22 19:14:29 +08:00
|
|
|
|
2002-08-26 19:35:56 +08:00
|
|
|
/* high output spin */
|
|
|
|
data = gtk_adjustment_new (255, 0, 255, 1, 10, 10);
|
|
|
|
l_tool->high_output_data = GTK_ADJUSTMENT (data);
|
|
|
|
|
|
|
|
spinbutton = gtk_spin_button_new (l_tool->high_output_data, 0.5, 0);
|
|
|
|
gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbutton), TRUE);
|
|
|
|
gtk_box_pack_end (GTK_BOX (hbox), spinbutton, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (spinbutton);
|
1999-11-22 19:14:29 +08:00
|
|
|
|
2003-01-06 06:07:10 +08:00
|
|
|
g_signal_connect (l_tool->high_output_data, "value_changed",
|
2002-08-26 19:35:56 +08:00
|
|
|
G_CALLBACK (levels_high_output_adjustment_update),
|
|
|
|
l_tool);
|
1999-08-27 08:19:25 +08:00
|
|
|
|
1999-11-22 19:14:29 +08:00
|
|
|
|
2002-08-29 03:47:07 +08:00
|
|
|
frame = gtk_frame_new (_("All Channels"));
|
|
|
|
gtk_box_pack_end (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (frame);
|
|
|
|
|
2003-03-17 01:00:40 +08:00
|
|
|
hbox = gtk_hbox_new (FALSE, 0);
|
|
|
|
gtk_container_add (GTK_CONTAINER (frame), hbox);
|
|
|
|
gtk_widget_show (hbox);
|
|
|
|
|
1999-11-22 19:14:29 +08:00
|
|
|
hbbox = gtk_hbutton_box_new ();
|
2002-08-29 03:47:07 +08:00
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (hbbox), 2);
|
2001-12-29 21:26:29 +08:00
|
|
|
gtk_box_set_spacing (GTK_BOX (hbbox), 4);
|
1999-11-22 19:14:29 +08:00
|
|
|
gtk_button_box_set_layout (GTK_BUTTON_BOX (hbbox), GTK_BUTTONBOX_SPREAD);
|
2003-03-19 20:23:03 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), hbbox, FALSE, FALSE, 0);
|
2002-08-26 19:35:56 +08:00
|
|
|
gtk_widget_show (hbbox);
|
1999-11-22 19:14:29 +08:00
|
|
|
|
2002-08-29 03:47:07 +08:00
|
|
|
button = gtk_button_new_from_stock (GTK_STOCK_OPEN);
|
1999-08-28 05:06:00 +08:00
|
|
|
GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
|
1999-08-27 08:19:25 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (hbbox), button, FALSE, FALSE, 0);
|
2002-08-29 03:47:07 +08:00
|
|
|
gimp_help_set_help_data (button, _("Read levels settings from file"), NULL);
|
2002-08-26 19:35:56 +08:00
|
|
|
gtk_widget_show (button);
|
1999-11-22 19:14:29 +08:00
|
|
|
|
2003-01-06 06:07:10 +08:00
|
|
|
g_signal_connect (button, "clicked",
|
2001-08-01 10:57:58 +08:00
|
|
|
G_CALLBACK (levels_load_callback),
|
2002-08-26 19:35:56 +08:00
|
|
|
l_tool);
|
1999-08-27 08:19:25 +08:00
|
|
|
|
2002-08-29 03:47:07 +08:00
|
|
|
button = gtk_button_new_from_stock (GTK_STOCK_SAVE);
|
1999-08-28 05:06:00 +08:00
|
|
|
GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
|
1999-08-27 08:19:25 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (hbbox), button, FALSE, FALSE, 0);
|
2002-08-29 03:47:07 +08:00
|
|
|
gimp_help_set_help_data (button, _("Save levels settings to file"), NULL);
|
2002-08-26 19:35:56 +08:00
|
|
|
gtk_widget_show (button);
|
1999-11-22 19:14:29 +08:00
|
|
|
|
2003-01-06 06:07:10 +08:00
|
|
|
g_signal_connect (button, "clicked",
|
2001-08-01 10:57:58 +08:00
|
|
|
G_CALLBACK (levels_save_callback),
|
2002-08-26 19:35:56 +08:00
|
|
|
l_tool);
|
2003-03-17 01:00:40 +08:00
|
|
|
|
|
|
|
hbbox = gtk_hbox_new (FALSE, 4);
|
2003-03-19 20:23:03 +08:00
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (hbbox), 2);
|
2003-03-17 01:00:40 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), hbbox, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (hbbox);
|
|
|
|
|
2003-03-19 20:23:03 +08:00
|
|
|
button = gtk_button_new_with_mnemonic (_("_Auto"));
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbbox), button, FALSE, FALSE, 2);
|
|
|
|
gimp_help_set_help_data (button, _("Adjust levels automatically"), NULL);
|
2003-03-17 01:00:40 +08:00
|
|
|
gtk_widget_show (button);
|
|
|
|
|
2003-03-19 20:23:03 +08:00
|
|
|
g_signal_connect (button, "clicked",
|
|
|
|
G_CALLBACK (levels_auto_callback),
|
|
|
|
l_tool);
|
|
|
|
|
|
|
|
button = gimp_levels_tool_color_picker_new (l_tool,
|
|
|
|
LOW_INPUT | ALL_CHANNELS);
|
2003-03-17 01:00:40 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (hbbox), button, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (button);
|
|
|
|
|
2003-03-19 20:23:03 +08:00
|
|
|
button = gimp_levels_tool_color_picker_new (l_tool, GAMMA | ALL_CHANNELS);
|
2003-03-17 01:00:40 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (hbbox), button, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (button);
|
|
|
|
|
2003-03-19 20:23:03 +08:00
|
|
|
button = gimp_levels_tool_color_picker_new (l_tool,
|
|
|
|
HIGH_INPUT | ALL_CHANNELS);
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbbox), button, FALSE, FALSE, 0);
|
2003-03-17 01:00:40 +08:00
|
|
|
gtk_widget_show (button);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2001-10-17 19:33:43 +08:00
|
|
|
static void
|
2002-08-26 19:35:56 +08:00
|
|
|
gimp_levels_tool_reset (GimpImageMapTool *image_map_tool)
|
2001-10-17 19:33:43 +08:00
|
|
|
{
|
2003-03-17 01:00:40 +08:00
|
|
|
GimpLevelsTool *l_tool = GIMP_LEVELS_TOOL (image_map_tool);
|
2002-08-26 19:35:56 +08:00
|
|
|
|
More color correction stuff cleanup:
2002-09-04 Michael Natterer <mitch@gimp.org>
More color correction stuff cleanup:
* app/base/Makefile.am
* app/base/base-types.h
* app/base/levels.[ch]: new files containing levels_lut_func(), a
new "Levels" parameter struct and the "auto levels" stuff.
* app/base/lut-funcs.[ch]: removed the levels stuff here, added
lots of g_return_if_fail().
* app/base/color-balance.[ch]
* app/base/hue-saturation.[ch]: added init() and reset() functions
so we don't need to duplicate this code in the tool and the pdb
wrappers.
* app/base/curves.[ch]: s/gint/GimpHistogramChannel/g, made
curves_channel_reset() initialize the curves array.
* app/tools/gimpcolorbalancetool.[ch]: use the new functions,
moved the "Range" frame to the top, added a per-range "Reset"
button, made the global "Reset" button reset all ranges and
the "Preserve Luminosity" toggle.
* app/tools/gimpcurvestool.[ch]: don't initialize the curves
array manually, as curves_channel_reset() does that,
s/gint/GimpHistogramChannel/g.
* app/tools/gimphuesaturationtool.c: use the new functions, added
a per-channel "Reset" button and made the global "Reset" button
reset all channels, cleaned up the GUI update function.
* app/tools/gimplevelstool.[ch]: changed to use the new Levels
parameter struct and it's utility functions. Removed stuff
which now lives in base/levels.c
* app/tools/gimpimagemaptool.c: align the "Preview" button
bottom-left, not bottom-right.
* tools/pdbgen/pdb/color.pdb: use the new stuff and removed
uglyness because using the "Levels" struct makes the code more
straightforward.
* app/pdb/color_cmds.c: regenerated.
2002-09-04 23:25:15 +08:00
|
|
|
levels_init (l_tool->levels);
|
2002-08-26 19:35:56 +08:00
|
|
|
levels_update (l_tool, ALL);
|
2001-10-17 19:33:43 +08:00
|
|
|
}
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
static void
|
|
|
|
levels_draw_slider (GdkWindow *window,
|
|
|
|
GdkGC *border_gc,
|
|
|
|
GdkGC *fill_gc,
|
1999-11-22 19:14:29 +08:00
|
|
|
gint xpos)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
int y;
|
|
|
|
|
|
|
|
for (y = 0; y < CONTROL_HEIGHT; y++)
|
2002-10-15 21:36:28 +08:00
|
|
|
gdk_draw_line (window, fill_gc,
|
|
|
|
xpos - y / 2, y,
|
|
|
|
xpos + y / 2, y);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-10-15 21:36:28 +08:00
|
|
|
gdk_draw_line (window, border_gc,
|
|
|
|
xpos, 0,
|
1999-11-22 19:14:29 +08:00
|
|
|
xpos - (CONTROL_HEIGHT - 1) / 2, CONTROL_HEIGHT - 1);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-10-15 21:36:28 +08:00
|
|
|
gdk_draw_line (window, border_gc,
|
|
|
|
xpos, 0,
|
1999-11-22 19:14:29 +08:00
|
|
|
xpos + (CONTROL_HEIGHT - 1) / 2, CONTROL_HEIGHT - 1);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-10-15 21:36:28 +08:00
|
|
|
gdk_draw_line (window, border_gc,
|
|
|
|
xpos - (CONTROL_HEIGHT - 1) / 2, CONTROL_HEIGHT - 1,
|
1999-11-22 19:14:29 +08:00
|
|
|
xpos + (CONTROL_HEIGHT - 1) / 2, CONTROL_HEIGHT - 1);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
levels_erase_slider (GdkWindow *window,
|
1999-11-22 19:14:29 +08:00
|
|
|
gint xpos)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
gdk_window_clear_area (window, xpos - (CONTROL_HEIGHT - 1) / 2, 0,
|
|
|
|
CONTROL_HEIGHT - 1, CONTROL_HEIGHT);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2002-08-26 19:35:56 +08:00
|
|
|
levels_update (GimpLevelsTool *l_tool,
|
|
|
|
gint update)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1999-11-22 19:14:29 +08:00
|
|
|
gint i;
|
2002-08-26 19:35:56 +08:00
|
|
|
gint sel_channel;
|
2000-12-01 07:23:59 +08:00
|
|
|
|
2002-08-26 19:35:56 +08:00
|
|
|
if (l_tool->color)
|
2001-01-03 10:59:57 +08:00
|
|
|
{
|
2002-08-26 19:35:56 +08:00
|
|
|
sel_channel = l_tool->channel;
|
2001-01-03 10:59:57 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2002-08-26 19:35:56 +08:00
|
|
|
if (l_tool->channel == 2)
|
2001-01-03 10:59:57 +08:00
|
|
|
sel_channel = GIMP_HISTOGRAM_ALPHA;
|
|
|
|
else
|
|
|
|
sel_channel = GIMP_HISTOGRAM_VALUE;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* Recalculate the transfer arrays */
|
More color correction stuff cleanup:
2002-09-04 Michael Natterer <mitch@gimp.org>
More color correction stuff cleanup:
* app/base/Makefile.am
* app/base/base-types.h
* app/base/levels.[ch]: new files containing levels_lut_func(), a
new "Levels" parameter struct and the "auto levels" stuff.
* app/base/lut-funcs.[ch]: removed the levels stuff here, added
lots of g_return_if_fail().
* app/base/color-balance.[ch]
* app/base/hue-saturation.[ch]: added init() and reset() functions
so we don't need to duplicate this code in the tool and the pdb
wrappers.
* app/base/curves.[ch]: s/gint/GimpHistogramChannel/g, made
curves_channel_reset() initialize the curves array.
* app/tools/gimpcolorbalancetool.[ch]: use the new functions,
moved the "Range" frame to the top, added a per-range "Reset"
button, made the global "Reset" button reset all ranges and
the "Preserve Luminosity" toggle.
* app/tools/gimpcurvestool.[ch]: don't initialize the curves
array manually, as curves_channel_reset() does that,
s/gint/GimpHistogramChannel/g.
* app/tools/gimphuesaturationtool.c: use the new functions, added
a per-channel "Reset" button and made the global "Reset" button
reset all channels, cleaned up the GUI update function.
* app/tools/gimplevelstool.[ch]: changed to use the new Levels
parameter struct and it's utility functions. Removed stuff
which now lives in base/levels.c
* app/tools/gimpimagemaptool.c: align the "Preview" button
bottom-left, not bottom-right.
* tools/pdbgen/pdb/color.pdb: use the new stuff and removed
uglyness because using the "Levels" struct makes the code more
straightforward.
* app/pdb/color_cmds.c: regenerated.
2002-09-04 23:25:15 +08:00
|
|
|
levels_calculate_transfers (l_tool->levels);
|
2002-08-26 19:35:56 +08:00
|
|
|
|
1999-02-16 16:53:54 +08:00
|
|
|
/* set up the lut */
|
More color correction stuff cleanup:
2002-09-04 Michael Natterer <mitch@gimp.org>
More color correction stuff cleanup:
* app/base/Makefile.am
* app/base/base-types.h
* app/base/levels.[ch]: new files containing levels_lut_func(), a
new "Levels" parameter struct and the "auto levels" stuff.
* app/base/lut-funcs.[ch]: removed the levels stuff here, added
lots of g_return_if_fail().
* app/base/color-balance.[ch]
* app/base/hue-saturation.[ch]: added init() and reset() functions
so we don't need to duplicate this code in the tool and the pdb
wrappers.
* app/base/curves.[ch]: s/gint/GimpHistogramChannel/g, made
curves_channel_reset() initialize the curves array.
* app/tools/gimpcolorbalancetool.[ch]: use the new functions,
moved the "Range" frame to the top, added a per-range "Reset"
button, made the global "Reset" button reset all ranges and
the "Preserve Luminosity" toggle.
* app/tools/gimpcurvestool.[ch]: don't initialize the curves
array manually, as curves_channel_reset() does that,
s/gint/GimpHistogramChannel/g.
* app/tools/gimphuesaturationtool.c: use the new functions, added
a per-channel "Reset" button and made the global "Reset" button
reset all channels, cleaned up the GUI update function.
* app/tools/gimplevelstool.[ch]: changed to use the new Levels
parameter struct and it's utility functions. Removed stuff
which now lives in base/levels.c
* app/tools/gimpimagemaptool.c: align the "Preview" button
bottom-left, not bottom-right.
* tools/pdbgen/pdb/color.pdb: use the new stuff and removed
uglyness because using the "Levels" struct makes the code more
straightforward.
* app/pdb/color_cmds.c: regenerated.
2002-09-04 23:25:15 +08:00
|
|
|
gimp_lut_setup (l_tool->lut,
|
|
|
|
(GimpLutFunc) levels_lut_func,
|
|
|
|
l_tool->levels,
|
|
|
|
gimp_drawable_bytes (GIMP_IMAGE_MAP_TOOL (l_tool)->drawable));
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
if (update & LOW_INPUT)
|
2002-08-26 19:35:56 +08:00
|
|
|
gtk_adjustment_set_value (l_tool->low_input_data,
|
More color correction stuff cleanup:
2002-09-04 Michael Natterer <mitch@gimp.org>
More color correction stuff cleanup:
* app/base/Makefile.am
* app/base/base-types.h
* app/base/levels.[ch]: new files containing levels_lut_func(), a
new "Levels" parameter struct and the "auto levels" stuff.
* app/base/lut-funcs.[ch]: removed the levels stuff here, added
lots of g_return_if_fail().
* app/base/color-balance.[ch]
* app/base/hue-saturation.[ch]: added init() and reset() functions
so we don't need to duplicate this code in the tool and the pdb
wrappers.
* app/base/curves.[ch]: s/gint/GimpHistogramChannel/g, made
curves_channel_reset() initialize the curves array.
* app/tools/gimpcolorbalancetool.[ch]: use the new functions,
moved the "Range" frame to the top, added a per-range "Reset"
button, made the global "Reset" button reset all ranges and
the "Preserve Luminosity" toggle.
* app/tools/gimpcurvestool.[ch]: don't initialize the curves
array manually, as curves_channel_reset() does that,
s/gint/GimpHistogramChannel/g.
* app/tools/gimphuesaturationtool.c: use the new functions, added
a per-channel "Reset" button and made the global "Reset" button
reset all channels, cleaned up the GUI update function.
* app/tools/gimplevelstool.[ch]: changed to use the new Levels
parameter struct and it's utility functions. Removed stuff
which now lives in base/levels.c
* app/tools/gimpimagemaptool.c: align the "Preview" button
bottom-left, not bottom-right.
* tools/pdbgen/pdb/color.pdb: use the new stuff and removed
uglyness because using the "Levels" struct makes the code more
straightforward.
* app/pdb/color_cmds.c: regenerated.
2002-09-04 23:25:15 +08:00
|
|
|
l_tool->levels->low_input[l_tool->channel]);
|
2002-08-26 19:35:56 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
if (update & GAMMA)
|
2002-08-26 19:35:56 +08:00
|
|
|
gtk_adjustment_set_value (l_tool->gamma_data,
|
More color correction stuff cleanup:
2002-09-04 Michael Natterer <mitch@gimp.org>
More color correction stuff cleanup:
* app/base/Makefile.am
* app/base/base-types.h
* app/base/levels.[ch]: new files containing levels_lut_func(), a
new "Levels" parameter struct and the "auto levels" stuff.
* app/base/lut-funcs.[ch]: removed the levels stuff here, added
lots of g_return_if_fail().
* app/base/color-balance.[ch]
* app/base/hue-saturation.[ch]: added init() and reset() functions
so we don't need to duplicate this code in the tool and the pdb
wrappers.
* app/base/curves.[ch]: s/gint/GimpHistogramChannel/g, made
curves_channel_reset() initialize the curves array.
* app/tools/gimpcolorbalancetool.[ch]: use the new functions,
moved the "Range" frame to the top, added a per-range "Reset"
button, made the global "Reset" button reset all ranges and
the "Preserve Luminosity" toggle.
* app/tools/gimpcurvestool.[ch]: don't initialize the curves
array manually, as curves_channel_reset() does that,
s/gint/GimpHistogramChannel/g.
* app/tools/gimphuesaturationtool.c: use the new functions, added
a per-channel "Reset" button and made the global "Reset" button
reset all channels, cleaned up the GUI update function.
* app/tools/gimplevelstool.[ch]: changed to use the new Levels
parameter struct and it's utility functions. Removed stuff
which now lives in base/levels.c
* app/tools/gimpimagemaptool.c: align the "Preview" button
bottom-left, not bottom-right.
* tools/pdbgen/pdb/color.pdb: use the new stuff and removed
uglyness because using the "Levels" struct makes the code more
straightforward.
* app/pdb/color_cmds.c: regenerated.
2002-09-04 23:25:15 +08:00
|
|
|
l_tool->levels->gamma[l_tool->channel]);
|
2002-08-26 19:35:56 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
if (update & HIGH_INPUT)
|
2002-08-26 19:35:56 +08:00
|
|
|
gtk_adjustment_set_value (l_tool->high_input_data,
|
More color correction stuff cleanup:
2002-09-04 Michael Natterer <mitch@gimp.org>
More color correction stuff cleanup:
* app/base/Makefile.am
* app/base/base-types.h
* app/base/levels.[ch]: new files containing levels_lut_func(), a
new "Levels" parameter struct and the "auto levels" stuff.
* app/base/lut-funcs.[ch]: removed the levels stuff here, added
lots of g_return_if_fail().
* app/base/color-balance.[ch]
* app/base/hue-saturation.[ch]: added init() and reset() functions
so we don't need to duplicate this code in the tool and the pdb
wrappers.
* app/base/curves.[ch]: s/gint/GimpHistogramChannel/g, made
curves_channel_reset() initialize the curves array.
* app/tools/gimpcolorbalancetool.[ch]: use the new functions,
moved the "Range" frame to the top, added a per-range "Reset"
button, made the global "Reset" button reset all ranges and
the "Preserve Luminosity" toggle.
* app/tools/gimpcurvestool.[ch]: don't initialize the curves
array manually, as curves_channel_reset() does that,
s/gint/GimpHistogramChannel/g.
* app/tools/gimphuesaturationtool.c: use the new functions, added
a per-channel "Reset" button and made the global "Reset" button
reset all channels, cleaned up the GUI update function.
* app/tools/gimplevelstool.[ch]: changed to use the new Levels
parameter struct and it's utility functions. Removed stuff
which now lives in base/levels.c
* app/tools/gimpimagemaptool.c: align the "Preview" button
bottom-left, not bottom-right.
* tools/pdbgen/pdb/color.pdb: use the new stuff and removed
uglyness because using the "Levels" struct makes the code more
straightforward.
* app/pdb/color_cmds.c: regenerated.
2002-09-04 23:25:15 +08:00
|
|
|
l_tool->levels->high_input[l_tool->channel]);
|
2002-08-26 19:35:56 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
if (update & LOW_OUTPUT)
|
2002-08-26 19:35:56 +08:00
|
|
|
gtk_adjustment_set_value (l_tool->low_output_data,
|
More color correction stuff cleanup:
2002-09-04 Michael Natterer <mitch@gimp.org>
More color correction stuff cleanup:
* app/base/Makefile.am
* app/base/base-types.h
* app/base/levels.[ch]: new files containing levels_lut_func(), a
new "Levels" parameter struct and the "auto levels" stuff.
* app/base/lut-funcs.[ch]: removed the levels stuff here, added
lots of g_return_if_fail().
* app/base/color-balance.[ch]
* app/base/hue-saturation.[ch]: added init() and reset() functions
so we don't need to duplicate this code in the tool and the pdb
wrappers.
* app/base/curves.[ch]: s/gint/GimpHistogramChannel/g, made
curves_channel_reset() initialize the curves array.
* app/tools/gimpcolorbalancetool.[ch]: use the new functions,
moved the "Range" frame to the top, added a per-range "Reset"
button, made the global "Reset" button reset all ranges and
the "Preserve Luminosity" toggle.
* app/tools/gimpcurvestool.[ch]: don't initialize the curves
array manually, as curves_channel_reset() does that,
s/gint/GimpHistogramChannel/g.
* app/tools/gimphuesaturationtool.c: use the new functions, added
a per-channel "Reset" button and made the global "Reset" button
reset all channels, cleaned up the GUI update function.
* app/tools/gimplevelstool.[ch]: changed to use the new Levels
parameter struct and it's utility functions. Removed stuff
which now lives in base/levels.c
* app/tools/gimpimagemaptool.c: align the "Preview" button
bottom-left, not bottom-right.
* tools/pdbgen/pdb/color.pdb: use the new stuff and removed
uglyness because using the "Levels" struct makes the code more
straightforward.
* app/pdb/color_cmds.c: regenerated.
2002-09-04 23:25:15 +08:00
|
|
|
l_tool->levels->low_output[l_tool->channel]);
|
2002-08-26 19:35:56 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
if (update & HIGH_OUTPUT)
|
2002-08-26 19:35:56 +08:00
|
|
|
gtk_adjustment_set_value (l_tool->high_output_data,
|
More color correction stuff cleanup:
2002-09-04 Michael Natterer <mitch@gimp.org>
More color correction stuff cleanup:
* app/base/Makefile.am
* app/base/base-types.h
* app/base/levels.[ch]: new files containing levels_lut_func(), a
new "Levels" parameter struct and the "auto levels" stuff.
* app/base/lut-funcs.[ch]: removed the levels stuff here, added
lots of g_return_if_fail().
* app/base/color-balance.[ch]
* app/base/hue-saturation.[ch]: added init() and reset() functions
so we don't need to duplicate this code in the tool and the pdb
wrappers.
* app/base/curves.[ch]: s/gint/GimpHistogramChannel/g, made
curves_channel_reset() initialize the curves array.
* app/tools/gimpcolorbalancetool.[ch]: use the new functions,
moved the "Range" frame to the top, added a per-range "Reset"
button, made the global "Reset" button reset all ranges and
the "Preserve Luminosity" toggle.
* app/tools/gimpcurvestool.[ch]: don't initialize the curves
array manually, as curves_channel_reset() does that,
s/gint/GimpHistogramChannel/g.
* app/tools/gimphuesaturationtool.c: use the new functions, added
a per-channel "Reset" button and made the global "Reset" button
reset all channels, cleaned up the GUI update function.
* app/tools/gimplevelstool.[ch]: changed to use the new Levels
parameter struct and it's utility functions. Removed stuff
which now lives in base/levels.c
* app/tools/gimpimagemaptool.c: align the "Preview" button
bottom-left, not bottom-right.
* tools/pdbgen/pdb/color.pdb: use the new stuff and removed
uglyness because using the "Levels" struct makes the code more
straightforward.
* app/pdb/color_cmds.c: regenerated.
2002-09-04 23:25:15 +08:00
|
|
|
l_tool->levels->high_output[l_tool->channel]);
|
2002-08-26 19:35:56 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
if (update & INPUT_LEVELS)
|
|
|
|
{
|
1999-11-22 19:14:29 +08:00
|
|
|
guchar buf[DA_WIDTH*3];
|
1999-07-06 03:49:55 +08:00
|
|
|
|
2000-12-01 07:23:59 +08:00
|
|
|
switch (sel_channel)
|
1999-11-22 19:14:29 +08:00
|
|
|
{
|
|
|
|
default:
|
1999-07-06 03:49:55 +08:00
|
|
|
g_warning ("unknown channel type, can't happen\n");
|
|
|
|
/* fall through */
|
2000-12-19 22:43:54 +08:00
|
|
|
case GIMP_HISTOGRAM_VALUE:
|
|
|
|
case GIMP_HISTOGRAM_ALPHA:
|
1999-07-06 03:49:55 +08:00
|
|
|
for (i = 0; i < DA_WIDTH; i++)
|
1999-11-22 19:14:29 +08:00
|
|
|
{
|
More color correction stuff cleanup:
2002-09-04 Michael Natterer <mitch@gimp.org>
More color correction stuff cleanup:
* app/base/Makefile.am
* app/base/base-types.h
* app/base/levels.[ch]: new files containing levels_lut_func(), a
new "Levels" parameter struct and the "auto levels" stuff.
* app/base/lut-funcs.[ch]: removed the levels stuff here, added
lots of g_return_if_fail().
* app/base/color-balance.[ch]
* app/base/hue-saturation.[ch]: added init() and reset() functions
so we don't need to duplicate this code in the tool and the pdb
wrappers.
* app/base/curves.[ch]: s/gint/GimpHistogramChannel/g, made
curves_channel_reset() initialize the curves array.
* app/tools/gimpcolorbalancetool.[ch]: use the new functions,
moved the "Range" frame to the top, added a per-range "Reset"
button, made the global "Reset" button reset all ranges and
the "Preserve Luminosity" toggle.
* app/tools/gimpcurvestool.[ch]: don't initialize the curves
array manually, as curves_channel_reset() does that,
s/gint/GimpHistogramChannel/g.
* app/tools/gimphuesaturationtool.c: use the new functions, added
a per-channel "Reset" button and made the global "Reset" button
reset all channels, cleaned up the GUI update function.
* app/tools/gimplevelstool.[ch]: changed to use the new Levels
parameter struct and it's utility functions. Removed stuff
which now lives in base/levels.c
* app/tools/gimpimagemaptool.c: align the "Preview" button
bottom-left, not bottom-right.
* tools/pdbgen/pdb/color.pdb: use the new stuff and removed
uglyness because using the "Levels" struct makes the code more
straightforward.
* app/pdb/color_cmds.c: regenerated.
2002-09-04 23:25:15 +08:00
|
|
|
buf[3 * i + 0] = l_tool->levels->input[sel_channel][i];
|
|
|
|
buf[3 * i + 1] = l_tool->levels->input[sel_channel][i];
|
|
|
|
buf[3 * i + 2] = l_tool->levels->input[sel_channel][i];
|
1999-11-22 19:14:29 +08:00
|
|
|
}
|
1999-07-06 03:49:55 +08:00
|
|
|
break;
|
|
|
|
|
2000-12-19 22:43:54 +08:00
|
|
|
case GIMP_HISTOGRAM_RED:
|
|
|
|
case GIMP_HISTOGRAM_GREEN:
|
|
|
|
case GIMP_HISTOGRAM_BLUE:
|
1999-07-06 03:49:55 +08:00
|
|
|
for (i = 0; i < DA_WIDTH; i++)
|
1999-11-22 19:14:29 +08:00
|
|
|
{
|
More color correction stuff cleanup:
2002-09-04 Michael Natterer <mitch@gimp.org>
More color correction stuff cleanup:
* app/base/Makefile.am
* app/base/base-types.h
* app/base/levels.[ch]: new files containing levels_lut_func(), a
new "Levels" parameter struct and the "auto levels" stuff.
* app/base/lut-funcs.[ch]: removed the levels stuff here, added
lots of g_return_if_fail().
* app/base/color-balance.[ch]
* app/base/hue-saturation.[ch]: added init() and reset() functions
so we don't need to duplicate this code in the tool and the pdb
wrappers.
* app/base/curves.[ch]: s/gint/GimpHistogramChannel/g, made
curves_channel_reset() initialize the curves array.
* app/tools/gimpcolorbalancetool.[ch]: use the new functions,
moved the "Range" frame to the top, added a per-range "Reset"
button, made the global "Reset" button reset all ranges and
the "Preserve Luminosity" toggle.
* app/tools/gimpcurvestool.[ch]: don't initialize the curves
array manually, as curves_channel_reset() does that,
s/gint/GimpHistogramChannel/g.
* app/tools/gimphuesaturationtool.c: use the new functions, added
a per-channel "Reset" button and made the global "Reset" button
reset all channels, cleaned up the GUI update function.
* app/tools/gimplevelstool.[ch]: changed to use the new Levels
parameter struct and it's utility functions. Removed stuff
which now lives in base/levels.c
* app/tools/gimpimagemaptool.c: align the "Preview" button
bottom-left, not bottom-right.
* tools/pdbgen/pdb/color.pdb: use the new stuff and removed
uglyness because using the "Levels" struct makes the code more
straightforward.
* app/pdb/color_cmds.c: regenerated.
2002-09-04 23:25:15 +08:00
|
|
|
buf[3 * i + 0] = l_tool->levels->input[GIMP_HISTOGRAM_RED][i];
|
|
|
|
buf[3 * i + 1] = l_tool->levels->input[GIMP_HISTOGRAM_GREEN][i];
|
|
|
|
buf[3 * i + 2] = l_tool->levels->input[GIMP_HISTOGRAM_BLUE][i];
|
1999-11-22 19:14:29 +08:00
|
|
|
}
|
1999-07-06 03:49:55 +08:00
|
|
|
break;
|
1999-11-22 19:14:29 +08:00
|
|
|
}
|
1999-07-06 03:49:55 +08:00
|
|
|
|
|
|
|
for (i = 0; i < GRADIENT_HEIGHT/2; i++)
|
2002-08-26 19:35:56 +08:00
|
|
|
gtk_preview_draw_row (GTK_PREVIEW (l_tool->input_levels_da[0]),
|
1999-07-06 03:49:55 +08:00
|
|
|
buf, 0, i, DA_WIDTH);
|
|
|
|
|
|
|
|
for (i = 0; i < DA_WIDTH; i++)
|
1999-11-22 19:14:29 +08:00
|
|
|
{
|
2002-08-26 19:35:56 +08:00
|
|
|
buf[3 * i + 0] = i;
|
|
|
|
buf[3 * i + 1] = i;
|
|
|
|
buf[3 * i + 2] = i;
|
1999-11-22 19:14:29 +08:00
|
|
|
}
|
1999-07-06 03:49:55 +08:00
|
|
|
|
|
|
|
for (i = GRADIENT_HEIGHT/2; i < GRADIENT_HEIGHT; i++)
|
2002-08-26 19:35:56 +08:00
|
|
|
gtk_preview_draw_row (GTK_PREVIEW (l_tool->input_levels_da[0]),
|
1999-07-06 03:49:55 +08:00
|
|
|
buf, 0, i, DA_WIDTH);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
if (update & DRAW)
|
2002-08-26 19:35:56 +08:00
|
|
|
gtk_widget_queue_draw (l_tool->input_levels_da[0]);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
2002-08-26 19:35:56 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
if (update & OUTPUT_LEVELS)
|
|
|
|
{
|
1999-11-22 19:14:29 +08:00
|
|
|
guchar buf[DA_WIDTH*3];
|
|
|
|
guchar r, g, b;
|
1999-07-06 03:49:55 +08:00
|
|
|
|
|
|
|
r = g = b = 0;
|
2000-12-01 07:23:59 +08:00
|
|
|
switch (sel_channel)
|
1999-11-22 19:14:29 +08:00
|
|
|
{
|
|
|
|
default:
|
1999-07-06 03:49:55 +08:00
|
|
|
g_warning ("unknown channel type, can't happen\n");
|
|
|
|
/* fall through */
|
2000-12-19 22:43:54 +08:00
|
|
|
case GIMP_HISTOGRAM_VALUE:
|
|
|
|
case GIMP_HISTOGRAM_ALPHA: r = g = b = 1; break;
|
|
|
|
case GIMP_HISTOGRAM_RED: r = 1; break;
|
|
|
|
case GIMP_HISTOGRAM_GREEN: g = 1; break;
|
|
|
|
case GIMP_HISTOGRAM_BLUE: b = 1; break;
|
1999-11-22 19:14:29 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
for (i = 0; i < DA_WIDTH; i++)
|
1999-11-22 19:14:29 +08:00
|
|
|
{
|
2002-08-26 19:35:56 +08:00
|
|
|
buf[3 * i + 0] = i * r;
|
|
|
|
buf[3 * i + 1] = i * g;
|
|
|
|
buf[3 * i + 2] = i * b;
|
1999-11-22 19:14:29 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
for (i = 0; i < GRADIENT_HEIGHT; i++)
|
2002-08-26 19:35:56 +08:00
|
|
|
gtk_preview_draw_row (GTK_PREVIEW (l_tool->output_levels_da[0]),
|
1997-11-25 06:05:25 +08:00
|
|
|
buf, 0, i, DA_WIDTH);
|
|
|
|
|
|
|
|
if (update & DRAW)
|
2002-08-26 19:35:56 +08:00
|
|
|
gtk_widget_queue_draw (l_tool->output_levels_da[0]);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
2002-08-26 19:35:56 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
if (update & INPUT_SLIDERS)
|
|
|
|
{
|
2003-03-17 01:00:40 +08:00
|
|
|
gdouble width, mid, tmp;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-08-26 19:35:56 +08:00
|
|
|
levels_erase_slider (l_tool->input_levels_da[1]->window,
|
|
|
|
l_tool->slider_pos[0]);
|
|
|
|
levels_erase_slider (l_tool->input_levels_da[1]->window,
|
|
|
|
l_tool->slider_pos[1]);
|
|
|
|
levels_erase_slider (l_tool->input_levels_da[1]->window,
|
|
|
|
l_tool->slider_pos[2]);
|
|
|
|
|
|
|
|
l_tool->slider_pos[0] =
|
More color correction stuff cleanup:
2002-09-04 Michael Natterer <mitch@gimp.org>
More color correction stuff cleanup:
* app/base/Makefile.am
* app/base/base-types.h
* app/base/levels.[ch]: new files containing levels_lut_func(), a
new "Levels" parameter struct and the "auto levels" stuff.
* app/base/lut-funcs.[ch]: removed the levels stuff here, added
lots of g_return_if_fail().
* app/base/color-balance.[ch]
* app/base/hue-saturation.[ch]: added init() and reset() functions
so we don't need to duplicate this code in the tool and the pdb
wrappers.
* app/base/curves.[ch]: s/gint/GimpHistogramChannel/g, made
curves_channel_reset() initialize the curves array.
* app/tools/gimpcolorbalancetool.[ch]: use the new functions,
moved the "Range" frame to the top, added a per-range "Reset"
button, made the global "Reset" button reset all ranges and
the "Preserve Luminosity" toggle.
* app/tools/gimpcurvestool.[ch]: don't initialize the curves
array manually, as curves_channel_reset() does that,
s/gint/GimpHistogramChannel/g.
* app/tools/gimphuesaturationtool.c: use the new functions, added
a per-channel "Reset" button and made the global "Reset" button
reset all channels, cleaned up the GUI update function.
* app/tools/gimplevelstool.[ch]: changed to use the new Levels
parameter struct and it's utility functions. Removed stuff
which now lives in base/levels.c
* app/tools/gimpimagemaptool.c: align the "Preview" button
bottom-left, not bottom-right.
* tools/pdbgen/pdb/color.pdb: use the new stuff and removed
uglyness because using the "Levels" struct makes the code more
straightforward.
* app/pdb/color_cmds.c: regenerated.
2002-09-04 23:25:15 +08:00
|
|
|
DA_WIDTH * ((gdouble) l_tool->levels->low_input[l_tool->channel] / 255.0);
|
2002-08-26 19:35:56 +08:00
|
|
|
|
|
|
|
l_tool->slider_pos[2] =
|
More color correction stuff cleanup:
2002-09-04 Michael Natterer <mitch@gimp.org>
More color correction stuff cleanup:
* app/base/Makefile.am
* app/base/base-types.h
* app/base/levels.[ch]: new files containing levels_lut_func(), a
new "Levels" parameter struct and the "auto levels" stuff.
* app/base/lut-funcs.[ch]: removed the levels stuff here, added
lots of g_return_if_fail().
* app/base/color-balance.[ch]
* app/base/hue-saturation.[ch]: added init() and reset() functions
so we don't need to duplicate this code in the tool and the pdb
wrappers.
* app/base/curves.[ch]: s/gint/GimpHistogramChannel/g, made
curves_channel_reset() initialize the curves array.
* app/tools/gimpcolorbalancetool.[ch]: use the new functions,
moved the "Range" frame to the top, added a per-range "Reset"
button, made the global "Reset" button reset all ranges and
the "Preserve Luminosity" toggle.
* app/tools/gimpcurvestool.[ch]: don't initialize the curves
array manually, as curves_channel_reset() does that,
s/gint/GimpHistogramChannel/g.
* app/tools/gimphuesaturationtool.c: use the new functions, added
a per-channel "Reset" button and made the global "Reset" button
reset all channels, cleaned up the GUI update function.
* app/tools/gimplevelstool.[ch]: changed to use the new Levels
parameter struct and it's utility functions. Removed stuff
which now lives in base/levels.c
* app/tools/gimpimagemaptool.c: align the "Preview" button
bottom-left, not bottom-right.
* tools/pdbgen/pdb/color.pdb: use the new stuff and removed
uglyness because using the "Levels" struct makes the code more
straightforward.
* app/pdb/color_cmds.c: regenerated.
2002-09-04 23:25:15 +08:00
|
|
|
DA_WIDTH * ((gdouble) l_tool->levels->high_input[l_tool->channel] / 255.0);
|
2002-08-26 19:35:56 +08:00
|
|
|
|
2003-03-17 01:00:40 +08:00
|
|
|
width = (gdouble) (l_tool->slider_pos[2] - l_tool->slider_pos[0]) / 2.0;
|
2002-08-26 19:35:56 +08:00
|
|
|
mid = l_tool->slider_pos[0] + width;
|
More color correction stuff cleanup:
2002-09-04 Michael Natterer <mitch@gimp.org>
More color correction stuff cleanup:
* app/base/Makefile.am
* app/base/base-types.h
* app/base/levels.[ch]: new files containing levels_lut_func(), a
new "Levels" parameter struct and the "auto levels" stuff.
* app/base/lut-funcs.[ch]: removed the levels stuff here, added
lots of g_return_if_fail().
* app/base/color-balance.[ch]
* app/base/hue-saturation.[ch]: added init() and reset() functions
so we don't need to duplicate this code in the tool and the pdb
wrappers.
* app/base/curves.[ch]: s/gint/GimpHistogramChannel/g, made
curves_channel_reset() initialize the curves array.
* app/tools/gimpcolorbalancetool.[ch]: use the new functions,
moved the "Range" frame to the top, added a per-range "Reset"
button, made the global "Reset" button reset all ranges and
the "Preserve Luminosity" toggle.
* app/tools/gimpcurvestool.[ch]: don't initialize the curves
array manually, as curves_channel_reset() does that,
s/gint/GimpHistogramChannel/g.
* app/tools/gimphuesaturationtool.c: use the new functions, added
a per-channel "Reset" button and made the global "Reset" button
reset all channels, cleaned up the GUI update function.
* app/tools/gimplevelstool.[ch]: changed to use the new Levels
parameter struct and it's utility functions. Removed stuff
which now lives in base/levels.c
* app/tools/gimpimagemaptool.c: align the "Preview" button
bottom-left, not bottom-right.
* tools/pdbgen/pdb/color.pdb: use the new stuff and removed
uglyness because using the "Levels" struct makes the code more
straightforward.
* app/pdb/color_cmds.c: regenerated.
2002-09-04 23:25:15 +08:00
|
|
|
tmp = log10 (1.0 / l_tool->levels->gamma[l_tool->channel]);
|
2002-08-26 19:35:56 +08:00
|
|
|
|
|
|
|
l_tool->slider_pos[1] = (gint) (mid + width * tmp + 0.5);
|
|
|
|
|
|
|
|
levels_draw_slider (l_tool->input_levels_da[1]->window,
|
|
|
|
l_tool->input_levels_da[1]->style->black_gc,
|
|
|
|
l_tool->input_levels_da[1]->style->dark_gc[GTK_STATE_NORMAL],
|
|
|
|
l_tool->slider_pos[1]);
|
|
|
|
levels_draw_slider (l_tool->input_levels_da[1]->window,
|
|
|
|
l_tool->input_levels_da[1]->style->black_gc,
|
|
|
|
l_tool->input_levels_da[1]->style->black_gc,
|
|
|
|
l_tool->slider_pos[0]);
|
|
|
|
levels_draw_slider (l_tool->input_levels_da[1]->window,
|
|
|
|
l_tool->input_levels_da[1]->style->black_gc,
|
|
|
|
l_tool->input_levels_da[1]->style->white_gc,
|
|
|
|
l_tool->slider_pos[2]);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
2001-07-08 01:36:00 +08:00
|
|
|
|
2002-08-26 19:35:56 +08:00
|
|
|
if (update & OUTPUT_SLIDERS)
|
1999-11-22 19:14:29 +08:00
|
|
|
{
|
2002-08-26 19:35:56 +08:00
|
|
|
levels_erase_slider (l_tool->output_levels_da[1]->window,
|
|
|
|
l_tool->slider_pos[3]);
|
|
|
|
levels_erase_slider (l_tool->output_levels_da[1]->window,
|
|
|
|
l_tool->slider_pos[4]);
|
|
|
|
|
|
|
|
l_tool->slider_pos[3] =
|
More color correction stuff cleanup:
2002-09-04 Michael Natterer <mitch@gimp.org>
More color correction stuff cleanup:
* app/base/Makefile.am
* app/base/base-types.h
* app/base/levels.[ch]: new files containing levels_lut_func(), a
new "Levels" parameter struct and the "auto levels" stuff.
* app/base/lut-funcs.[ch]: removed the levels stuff here, added
lots of g_return_if_fail().
* app/base/color-balance.[ch]
* app/base/hue-saturation.[ch]: added init() and reset() functions
so we don't need to duplicate this code in the tool and the pdb
wrappers.
* app/base/curves.[ch]: s/gint/GimpHistogramChannel/g, made
curves_channel_reset() initialize the curves array.
* app/tools/gimpcolorbalancetool.[ch]: use the new functions,
moved the "Range" frame to the top, added a per-range "Reset"
button, made the global "Reset" button reset all ranges and
the "Preserve Luminosity" toggle.
* app/tools/gimpcurvestool.[ch]: don't initialize the curves
array manually, as curves_channel_reset() does that,
s/gint/GimpHistogramChannel/g.
* app/tools/gimphuesaturationtool.c: use the new functions, added
a per-channel "Reset" button and made the global "Reset" button
reset all channels, cleaned up the GUI update function.
* app/tools/gimplevelstool.[ch]: changed to use the new Levels
parameter struct and it's utility functions. Removed stuff
which now lives in base/levels.c
* app/tools/gimpimagemaptool.c: align the "Preview" button
bottom-left, not bottom-right.
* tools/pdbgen/pdb/color.pdb: use the new stuff and removed
uglyness because using the "Levels" struct makes the code more
straightforward.
* app/pdb/color_cmds.c: regenerated.
2002-09-04 23:25:15 +08:00
|
|
|
DA_WIDTH * ((gdouble) l_tool->levels->low_output[l_tool->channel] / 255.0);
|
2002-08-26 19:35:56 +08:00
|
|
|
|
|
|
|
l_tool->slider_pos[4] =
|
More color correction stuff cleanup:
2002-09-04 Michael Natterer <mitch@gimp.org>
More color correction stuff cleanup:
* app/base/Makefile.am
* app/base/base-types.h
* app/base/levels.[ch]: new files containing levels_lut_func(), a
new "Levels" parameter struct and the "auto levels" stuff.
* app/base/lut-funcs.[ch]: removed the levels stuff here, added
lots of g_return_if_fail().
* app/base/color-balance.[ch]
* app/base/hue-saturation.[ch]: added init() and reset() functions
so we don't need to duplicate this code in the tool and the pdb
wrappers.
* app/base/curves.[ch]: s/gint/GimpHistogramChannel/g, made
curves_channel_reset() initialize the curves array.
* app/tools/gimpcolorbalancetool.[ch]: use the new functions,
moved the "Range" frame to the top, added a per-range "Reset"
button, made the global "Reset" button reset all ranges and
the "Preserve Luminosity" toggle.
* app/tools/gimpcurvestool.[ch]: don't initialize the curves
array manually, as curves_channel_reset() does that,
s/gint/GimpHistogramChannel/g.
* app/tools/gimphuesaturationtool.c: use the new functions, added
a per-channel "Reset" button and made the global "Reset" button
reset all channels, cleaned up the GUI update function.
* app/tools/gimplevelstool.[ch]: changed to use the new Levels
parameter struct and it's utility functions. Removed stuff
which now lives in base/levels.c
* app/tools/gimpimagemaptool.c: align the "Preview" button
bottom-left, not bottom-right.
* tools/pdbgen/pdb/color.pdb: use the new stuff and removed
uglyness because using the "Levels" struct makes the code more
straightforward.
* app/pdb/color_cmds.c: regenerated.
2002-09-04 23:25:15 +08:00
|
|
|
DA_WIDTH * ((gdouble) l_tool->levels->high_output[l_tool->channel] / 255.0);
|
2002-08-26 19:35:56 +08:00
|
|
|
|
|
|
|
levels_draw_slider (l_tool->output_levels_da[1]->window,
|
|
|
|
l_tool->output_levels_da[1]->style->black_gc,
|
|
|
|
l_tool->output_levels_da[1]->style->black_gc,
|
|
|
|
l_tool->slider_pos[3]);
|
|
|
|
levels_draw_slider (l_tool->output_levels_da[1]->window,
|
|
|
|
l_tool->output_levels_da[1]->style->black_gc,
|
|
|
|
l_tool->output_levels_da[1]->style->white_gc,
|
|
|
|
l_tool->slider_pos[4]);
|
1999-11-22 19:14:29 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2002-12-18 23:57:25 +08:00
|
|
|
levels_channel_callback (GtkWidget *widget,
|
|
|
|
GimpLevelsTool *l_tool)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2002-08-26 19:35:56 +08:00
|
|
|
gimp_menu_item_update (widget, &l_tool->channel);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-08-26 19:35:56 +08:00
|
|
|
if (l_tool->color)
|
2001-10-17 19:33:43 +08:00
|
|
|
{
|
2002-10-15 09:15:43 +08:00
|
|
|
gimp_histogram_view_set_channel (GIMP_HISTOGRAM_VIEW (l_tool->hist_view),
|
|
|
|
l_tool->channel);
|
2001-10-17 19:33:43 +08:00
|
|
|
}
|
2000-12-01 07:23:59 +08:00
|
|
|
else
|
|
|
|
{
|
2002-10-15 09:15:43 +08:00
|
|
|
l_tool->channel = (l_tool->channel > 1) ? 2 : 1;
|
|
|
|
gimp_histogram_view_set_channel (GIMP_HISTOGRAM_VIEW (l_tool->hist_view),
|
|
|
|
l_tool->channel - 1);
|
2000-12-01 07:23:59 +08:00
|
|
|
}
|
2002-08-26 19:35:56 +08:00
|
|
|
|
|
|
|
levels_update (l_tool, ALL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2002-12-18 23:57:25 +08:00
|
|
|
levels_channel_reset_callback (GtkWidget *widget,
|
|
|
|
GimpLevelsTool *l_tool)
|
2002-08-26 19:35:56 +08:00
|
|
|
{
|
More color correction stuff cleanup:
2002-09-04 Michael Natterer <mitch@gimp.org>
More color correction stuff cleanup:
* app/base/Makefile.am
* app/base/base-types.h
* app/base/levels.[ch]: new files containing levels_lut_func(), a
new "Levels" parameter struct and the "auto levels" stuff.
* app/base/lut-funcs.[ch]: removed the levels stuff here, added
lots of g_return_if_fail().
* app/base/color-balance.[ch]
* app/base/hue-saturation.[ch]: added init() and reset() functions
so we don't need to duplicate this code in the tool and the pdb
wrappers.
* app/base/curves.[ch]: s/gint/GimpHistogramChannel/g, made
curves_channel_reset() initialize the curves array.
* app/tools/gimpcolorbalancetool.[ch]: use the new functions,
moved the "Range" frame to the top, added a per-range "Reset"
button, made the global "Reset" button reset all ranges and
the "Preserve Luminosity" toggle.
* app/tools/gimpcurvestool.[ch]: don't initialize the curves
array manually, as curves_channel_reset() does that,
s/gint/GimpHistogramChannel/g.
* app/tools/gimphuesaturationtool.c: use the new functions, added
a per-channel "Reset" button and made the global "Reset" button
reset all channels, cleaned up the GUI update function.
* app/tools/gimplevelstool.[ch]: changed to use the new Levels
parameter struct and it's utility functions. Removed stuff
which now lives in base/levels.c
* app/tools/gimpimagemaptool.c: align the "Preview" button
bottom-left, not bottom-right.
* tools/pdbgen/pdb/color.pdb: use the new stuff and removed
uglyness because using the "Levels" struct makes the code more
straightforward.
* app/pdb/color_cmds.c: regenerated.
2002-09-04 23:25:15 +08:00
|
|
|
levels_channel_reset (l_tool->levels, l_tool->channel);
|
2002-08-26 19:35:56 +08:00
|
|
|
levels_update (l_tool, ALL);
|
|
|
|
|
|
|
|
gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (l_tool));
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2002-03-18 00:35:05 +08:00
|
|
|
static gboolean
|
2002-08-26 19:35:56 +08:00
|
|
|
levels_set_sensitive_callback (gpointer item_data,
|
|
|
|
GimpLevelsTool *l_tool)
|
2002-03-18 00:35:05 +08:00
|
|
|
{
|
|
|
|
GimpHistogramChannel channel = GPOINTER_TO_INT (item_data);
|
|
|
|
|
|
|
|
switch (channel)
|
|
|
|
{
|
|
|
|
case GIMP_HISTOGRAM_VALUE:
|
|
|
|
return TRUE;
|
2002-08-26 19:35:56 +08:00
|
|
|
|
2002-03-18 00:35:05 +08:00
|
|
|
case GIMP_HISTOGRAM_RED:
|
|
|
|
case GIMP_HISTOGRAM_GREEN:
|
|
|
|
case GIMP_HISTOGRAM_BLUE:
|
2002-08-26 19:35:56 +08:00
|
|
|
return l_tool->color;
|
|
|
|
|
2002-03-18 00:35:05 +08:00
|
|
|
case GIMP_HISTOGRAM_ALPHA:
|
2002-08-26 19:35:56 +08:00
|
|
|
return gimp_drawable_has_alpha (GIMP_IMAGE_MAP_TOOL (l_tool)->drawable);
|
2002-03-18 00:35:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
1999-11-22 19:14:29 +08:00
|
|
|
static void
|
2002-12-18 23:57:25 +08:00
|
|
|
levels_auto_callback (GtkWidget *widget,
|
|
|
|
GimpLevelsTool *l_tool)
|
1999-11-22 19:14:29 +08:00
|
|
|
{
|
More color correction stuff cleanup:
2002-09-04 Michael Natterer <mitch@gimp.org>
More color correction stuff cleanup:
* app/base/Makefile.am
* app/base/base-types.h
* app/base/levels.[ch]: new files containing levels_lut_func(), a
new "Levels" parameter struct and the "auto levels" stuff.
* app/base/lut-funcs.[ch]: removed the levels stuff here, added
lots of g_return_if_fail().
* app/base/color-balance.[ch]
* app/base/hue-saturation.[ch]: added init() and reset() functions
so we don't need to duplicate this code in the tool and the pdb
wrappers.
* app/base/curves.[ch]: s/gint/GimpHistogramChannel/g, made
curves_channel_reset() initialize the curves array.
* app/tools/gimpcolorbalancetool.[ch]: use the new functions,
moved the "Range" frame to the top, added a per-range "Reset"
button, made the global "Reset" button reset all ranges and
the "Preserve Luminosity" toggle.
* app/tools/gimpcurvestool.[ch]: don't initialize the curves
array manually, as curves_channel_reset() does that,
s/gint/GimpHistogramChannel/g.
* app/tools/gimphuesaturationtool.c: use the new functions, added
a per-channel "Reset" button and made the global "Reset" button
reset all channels, cleaned up the GUI update function.
* app/tools/gimplevelstool.[ch]: changed to use the new Levels
parameter struct and it's utility functions. Removed stuff
which now lives in base/levels.c
* app/tools/gimpimagemaptool.c: align the "Preview" button
bottom-left, not bottom-right.
* tools/pdbgen/pdb/color.pdb: use the new stuff and removed
uglyness because using the "Levels" struct makes the code more
straightforward.
* app/pdb/color_cmds.c: regenerated.
2002-09-04 23:25:15 +08:00
|
|
|
levels_auto (l_tool->levels, l_tool->hist, l_tool->color);
|
2002-08-26 19:35:56 +08:00
|
|
|
levels_update (l_tool, ALL);
|
2000-06-13 17:13:16 +08:00
|
|
|
|
2002-08-26 19:35:56 +08:00
|
|
|
gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (l_tool));
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2002-12-18 23:57:25 +08:00
|
|
|
levels_low_input_adjustment_update (GtkAdjustment *adjustment,
|
|
|
|
GimpLevelsTool *l_tool)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2002-12-18 23:57:25 +08:00
|
|
|
gint value;
|
1999-11-22 19:14:29 +08:00
|
|
|
|
|
|
|
value = (gint) (adjustment->value + 0.5);
|
More color correction stuff cleanup:
2002-09-04 Michael Natterer <mitch@gimp.org>
More color correction stuff cleanup:
* app/base/Makefile.am
* app/base/base-types.h
* app/base/levels.[ch]: new files containing levels_lut_func(), a
new "Levels" parameter struct and the "auto levels" stuff.
* app/base/lut-funcs.[ch]: removed the levels stuff here, added
lots of g_return_if_fail().
* app/base/color-balance.[ch]
* app/base/hue-saturation.[ch]: added init() and reset() functions
so we don't need to duplicate this code in the tool and the pdb
wrappers.
* app/base/curves.[ch]: s/gint/GimpHistogramChannel/g, made
curves_channel_reset() initialize the curves array.
* app/tools/gimpcolorbalancetool.[ch]: use the new functions,
moved the "Range" frame to the top, added a per-range "Reset"
button, made the global "Reset" button reset all ranges and
the "Preserve Luminosity" toggle.
* app/tools/gimpcurvestool.[ch]: don't initialize the curves
array manually, as curves_channel_reset() does that,
s/gint/GimpHistogramChannel/g.
* app/tools/gimphuesaturationtool.c: use the new functions, added
a per-channel "Reset" button and made the global "Reset" button
reset all channels, cleaned up the GUI update function.
* app/tools/gimplevelstool.[ch]: changed to use the new Levels
parameter struct and it's utility functions. Removed stuff
which now lives in base/levels.c
* app/tools/gimpimagemaptool.c: align the "Preview" button
bottom-left, not bottom-right.
* tools/pdbgen/pdb/color.pdb: use the new stuff and removed
uglyness because using the "Levels" struct makes the code more
straightforward.
* app/pdb/color_cmds.c: regenerated.
2002-09-04 23:25:15 +08:00
|
|
|
value = CLAMP (value, 0, l_tool->levels->high_input[l_tool->channel]);
|
1999-11-22 19:14:29 +08:00
|
|
|
|
1999-04-13 12:59:07 +08:00
|
|
|
/* enforce a consistent displayed value (low_input <= high_input) */
|
1999-11-22 19:14:29 +08:00
|
|
|
gtk_adjustment_set_value (adjustment, value);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
More color correction stuff cleanup:
2002-09-04 Michael Natterer <mitch@gimp.org>
More color correction stuff cleanup:
* app/base/Makefile.am
* app/base/base-types.h
* app/base/levels.[ch]: new files containing levels_lut_func(), a
new "Levels" parameter struct and the "auto levels" stuff.
* app/base/lut-funcs.[ch]: removed the levels stuff here, added
lots of g_return_if_fail().
* app/base/color-balance.[ch]
* app/base/hue-saturation.[ch]: added init() and reset() functions
so we don't need to duplicate this code in the tool and the pdb
wrappers.
* app/base/curves.[ch]: s/gint/GimpHistogramChannel/g, made
curves_channel_reset() initialize the curves array.
* app/tools/gimpcolorbalancetool.[ch]: use the new functions,
moved the "Range" frame to the top, added a per-range "Reset"
button, made the global "Reset" button reset all ranges and
the "Preserve Luminosity" toggle.
* app/tools/gimpcurvestool.[ch]: don't initialize the curves
array manually, as curves_channel_reset() does that,
s/gint/GimpHistogramChannel/g.
* app/tools/gimphuesaturationtool.c: use the new functions, added
a per-channel "Reset" button and made the global "Reset" button
reset all channels, cleaned up the GUI update function.
* app/tools/gimplevelstool.[ch]: changed to use the new Levels
parameter struct and it's utility functions. Removed stuff
which now lives in base/levels.c
* app/tools/gimpimagemaptool.c: align the "Preview" button
bottom-left, not bottom-right.
* tools/pdbgen/pdb/color.pdb: use the new stuff and removed
uglyness because using the "Levels" struct makes the code more
straightforward.
* app/pdb/color_cmds.c: regenerated.
2002-09-04 23:25:15 +08:00
|
|
|
if (l_tool->levels->low_input[l_tool->channel] != value)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
More color correction stuff cleanup:
2002-09-04 Michael Natterer <mitch@gimp.org>
More color correction stuff cleanup:
* app/base/Makefile.am
* app/base/base-types.h
* app/base/levels.[ch]: new files containing levels_lut_func(), a
new "Levels" parameter struct and the "auto levels" stuff.
* app/base/lut-funcs.[ch]: removed the levels stuff here, added
lots of g_return_if_fail().
* app/base/color-balance.[ch]
* app/base/hue-saturation.[ch]: added init() and reset() functions
so we don't need to duplicate this code in the tool and the pdb
wrappers.
* app/base/curves.[ch]: s/gint/GimpHistogramChannel/g, made
curves_channel_reset() initialize the curves array.
* app/tools/gimpcolorbalancetool.[ch]: use the new functions,
moved the "Range" frame to the top, added a per-range "Reset"
button, made the global "Reset" button reset all ranges and
the "Preserve Luminosity" toggle.
* app/tools/gimpcurvestool.[ch]: don't initialize the curves
array manually, as curves_channel_reset() does that,
s/gint/GimpHistogramChannel/g.
* app/tools/gimphuesaturationtool.c: use the new functions, added
a per-channel "Reset" button and made the global "Reset" button
reset all channels, cleaned up the GUI update function.
* app/tools/gimplevelstool.[ch]: changed to use the new Levels
parameter struct and it's utility functions. Removed stuff
which now lives in base/levels.c
* app/tools/gimpimagemaptool.c: align the "Preview" button
bottom-left, not bottom-right.
* tools/pdbgen/pdb/color.pdb: use the new stuff and removed
uglyness because using the "Levels" struct makes the code more
straightforward.
* app/pdb/color_cmds.c: regenerated.
2002-09-04 23:25:15 +08:00
|
|
|
l_tool->levels->low_input[l_tool->channel] = value;
|
2002-08-26 19:35:56 +08:00
|
|
|
levels_update (l_tool, INPUT_LEVELS | INPUT_SLIDERS | DRAW);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-08-26 19:35:56 +08:00
|
|
|
gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (l_tool));
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2002-12-18 23:57:25 +08:00
|
|
|
levels_gamma_adjustment_update (GtkAdjustment *adjustment,
|
|
|
|
GimpLevelsTool *l_tool)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
More color correction stuff cleanup:
2002-09-04 Michael Natterer <mitch@gimp.org>
More color correction stuff cleanup:
* app/base/Makefile.am
* app/base/base-types.h
* app/base/levels.[ch]: new files containing levels_lut_func(), a
new "Levels" parameter struct and the "auto levels" stuff.
* app/base/lut-funcs.[ch]: removed the levels stuff here, added
lots of g_return_if_fail().
* app/base/color-balance.[ch]
* app/base/hue-saturation.[ch]: added init() and reset() functions
so we don't need to duplicate this code in the tool and the pdb
wrappers.
* app/base/curves.[ch]: s/gint/GimpHistogramChannel/g, made
curves_channel_reset() initialize the curves array.
* app/tools/gimpcolorbalancetool.[ch]: use the new functions,
moved the "Range" frame to the top, added a per-range "Reset"
button, made the global "Reset" button reset all ranges and
the "Preserve Luminosity" toggle.
* app/tools/gimpcurvestool.[ch]: don't initialize the curves
array manually, as curves_channel_reset() does that,
s/gint/GimpHistogramChannel/g.
* app/tools/gimphuesaturationtool.c: use the new functions, added
a per-channel "Reset" button and made the global "Reset" button
reset all channels, cleaned up the GUI update function.
* app/tools/gimplevelstool.[ch]: changed to use the new Levels
parameter struct and it's utility functions. Removed stuff
which now lives in base/levels.c
* app/tools/gimpimagemaptool.c: align the "Preview" button
bottom-left, not bottom-right.
* tools/pdbgen/pdb/color.pdb: use the new stuff and removed
uglyness because using the "Levels" struct makes the code more
straightforward.
* app/pdb/color_cmds.c: regenerated.
2002-09-04 23:25:15 +08:00
|
|
|
if (l_tool->levels->gamma[l_tool->channel] != adjustment->value)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
More color correction stuff cleanup:
2002-09-04 Michael Natterer <mitch@gimp.org>
More color correction stuff cleanup:
* app/base/Makefile.am
* app/base/base-types.h
* app/base/levels.[ch]: new files containing levels_lut_func(), a
new "Levels" parameter struct and the "auto levels" stuff.
* app/base/lut-funcs.[ch]: removed the levels stuff here, added
lots of g_return_if_fail().
* app/base/color-balance.[ch]
* app/base/hue-saturation.[ch]: added init() and reset() functions
so we don't need to duplicate this code in the tool and the pdb
wrappers.
* app/base/curves.[ch]: s/gint/GimpHistogramChannel/g, made
curves_channel_reset() initialize the curves array.
* app/tools/gimpcolorbalancetool.[ch]: use the new functions,
moved the "Range" frame to the top, added a per-range "Reset"
button, made the global "Reset" button reset all ranges and
the "Preserve Luminosity" toggle.
* app/tools/gimpcurvestool.[ch]: don't initialize the curves
array manually, as curves_channel_reset() does that,
s/gint/GimpHistogramChannel/g.
* app/tools/gimphuesaturationtool.c: use the new functions, added
a per-channel "Reset" button and made the global "Reset" button
reset all channels, cleaned up the GUI update function.
* app/tools/gimplevelstool.[ch]: changed to use the new Levels
parameter struct and it's utility functions. Removed stuff
which now lives in base/levels.c
* app/tools/gimpimagemaptool.c: align the "Preview" button
bottom-left, not bottom-right.
* tools/pdbgen/pdb/color.pdb: use the new stuff and removed
uglyness because using the "Levels" struct makes the code more
straightforward.
* app/pdb/color_cmds.c: regenerated.
2002-09-04 23:25:15 +08:00
|
|
|
l_tool->levels->gamma[l_tool->channel] = adjustment->value;
|
2002-08-26 19:35:56 +08:00
|
|
|
levels_update (l_tool, INPUT_LEVELS | INPUT_SLIDERS | DRAW);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-08-26 19:35:56 +08:00
|
|
|
gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (l_tool));
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2002-12-18 23:57:25 +08:00
|
|
|
levels_high_input_adjustment_update (GtkAdjustment *adjustment,
|
|
|
|
GimpLevelsTool *l_tool)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2002-12-18 23:57:25 +08:00
|
|
|
gint value;
|
1999-11-22 19:14:29 +08:00
|
|
|
|
|
|
|
value = (gint) (adjustment->value + 0.5);
|
More color correction stuff cleanup:
2002-09-04 Michael Natterer <mitch@gimp.org>
More color correction stuff cleanup:
* app/base/Makefile.am
* app/base/base-types.h
* app/base/levels.[ch]: new files containing levels_lut_func(), a
new "Levels" parameter struct and the "auto levels" stuff.
* app/base/lut-funcs.[ch]: removed the levels stuff here, added
lots of g_return_if_fail().
* app/base/color-balance.[ch]
* app/base/hue-saturation.[ch]: added init() and reset() functions
so we don't need to duplicate this code in the tool and the pdb
wrappers.
* app/base/curves.[ch]: s/gint/GimpHistogramChannel/g, made
curves_channel_reset() initialize the curves array.
* app/tools/gimpcolorbalancetool.[ch]: use the new functions,
moved the "Range" frame to the top, added a per-range "Reset"
button, made the global "Reset" button reset all ranges and
the "Preserve Luminosity" toggle.
* app/tools/gimpcurvestool.[ch]: don't initialize the curves
array manually, as curves_channel_reset() does that,
s/gint/GimpHistogramChannel/g.
* app/tools/gimphuesaturationtool.c: use the new functions, added
a per-channel "Reset" button and made the global "Reset" button
reset all channels, cleaned up the GUI update function.
* app/tools/gimplevelstool.[ch]: changed to use the new Levels
parameter struct and it's utility functions. Removed stuff
which now lives in base/levels.c
* app/tools/gimpimagemaptool.c: align the "Preview" button
bottom-left, not bottom-right.
* tools/pdbgen/pdb/color.pdb: use the new stuff and removed
uglyness because using the "Levels" struct makes the code more
straightforward.
* app/pdb/color_cmds.c: regenerated.
2002-09-04 23:25:15 +08:00
|
|
|
value = CLAMP (value, l_tool->levels->low_input[l_tool->channel], 255);
|
1999-11-22 19:14:29 +08:00
|
|
|
|
1999-04-13 12:59:07 +08:00
|
|
|
/* enforce a consistent displayed value (high_input >= low_input) */
|
1999-11-22 19:14:29 +08:00
|
|
|
gtk_adjustment_set_value (adjustment, value);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
More color correction stuff cleanup:
2002-09-04 Michael Natterer <mitch@gimp.org>
More color correction stuff cleanup:
* app/base/Makefile.am
* app/base/base-types.h
* app/base/levels.[ch]: new files containing levels_lut_func(), a
new "Levels" parameter struct and the "auto levels" stuff.
* app/base/lut-funcs.[ch]: removed the levels stuff here, added
lots of g_return_if_fail().
* app/base/color-balance.[ch]
* app/base/hue-saturation.[ch]: added init() and reset() functions
so we don't need to duplicate this code in the tool and the pdb
wrappers.
* app/base/curves.[ch]: s/gint/GimpHistogramChannel/g, made
curves_channel_reset() initialize the curves array.
* app/tools/gimpcolorbalancetool.[ch]: use the new functions,
moved the "Range" frame to the top, added a per-range "Reset"
button, made the global "Reset" button reset all ranges and
the "Preserve Luminosity" toggle.
* app/tools/gimpcurvestool.[ch]: don't initialize the curves
array manually, as curves_channel_reset() does that,
s/gint/GimpHistogramChannel/g.
* app/tools/gimphuesaturationtool.c: use the new functions, added
a per-channel "Reset" button and made the global "Reset" button
reset all channels, cleaned up the GUI update function.
* app/tools/gimplevelstool.[ch]: changed to use the new Levels
parameter struct and it's utility functions. Removed stuff
which now lives in base/levels.c
* app/tools/gimpimagemaptool.c: align the "Preview" button
bottom-left, not bottom-right.
* tools/pdbgen/pdb/color.pdb: use the new stuff and removed
uglyness because using the "Levels" struct makes the code more
straightforward.
* app/pdb/color_cmds.c: regenerated.
2002-09-04 23:25:15 +08:00
|
|
|
if (l_tool->levels->high_input[l_tool->channel] != value)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
More color correction stuff cleanup:
2002-09-04 Michael Natterer <mitch@gimp.org>
More color correction stuff cleanup:
* app/base/Makefile.am
* app/base/base-types.h
* app/base/levels.[ch]: new files containing levels_lut_func(), a
new "Levels" parameter struct and the "auto levels" stuff.
* app/base/lut-funcs.[ch]: removed the levels stuff here, added
lots of g_return_if_fail().
* app/base/color-balance.[ch]
* app/base/hue-saturation.[ch]: added init() and reset() functions
so we don't need to duplicate this code in the tool and the pdb
wrappers.
* app/base/curves.[ch]: s/gint/GimpHistogramChannel/g, made
curves_channel_reset() initialize the curves array.
* app/tools/gimpcolorbalancetool.[ch]: use the new functions,
moved the "Range" frame to the top, added a per-range "Reset"
button, made the global "Reset" button reset all ranges and
the "Preserve Luminosity" toggle.
* app/tools/gimpcurvestool.[ch]: don't initialize the curves
array manually, as curves_channel_reset() does that,
s/gint/GimpHistogramChannel/g.
* app/tools/gimphuesaturationtool.c: use the new functions, added
a per-channel "Reset" button and made the global "Reset" button
reset all channels, cleaned up the GUI update function.
* app/tools/gimplevelstool.[ch]: changed to use the new Levels
parameter struct and it's utility functions. Removed stuff
which now lives in base/levels.c
* app/tools/gimpimagemaptool.c: align the "Preview" button
bottom-left, not bottom-right.
* tools/pdbgen/pdb/color.pdb: use the new stuff and removed
uglyness because using the "Levels" struct makes the code more
straightforward.
* app/pdb/color_cmds.c: regenerated.
2002-09-04 23:25:15 +08:00
|
|
|
l_tool->levels->high_input[l_tool->channel] = value;
|
2002-08-26 19:35:56 +08:00
|
|
|
levels_update (l_tool, INPUT_LEVELS | INPUT_SLIDERS | DRAW);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-08-26 19:35:56 +08:00
|
|
|
gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (l_tool));
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2002-12-18 23:57:25 +08:00
|
|
|
levels_low_output_adjustment_update (GtkAdjustment *adjustment,
|
|
|
|
GimpLevelsTool *l_tool)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2002-12-18 23:57:25 +08:00
|
|
|
gint value;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-11-22 19:14:29 +08:00
|
|
|
value = (gint) (adjustment->value + 0.5);
|
|
|
|
|
More color correction stuff cleanup:
2002-09-04 Michael Natterer <mitch@gimp.org>
More color correction stuff cleanup:
* app/base/Makefile.am
* app/base/base-types.h
* app/base/levels.[ch]: new files containing levels_lut_func(), a
new "Levels" parameter struct and the "auto levels" stuff.
* app/base/lut-funcs.[ch]: removed the levels stuff here, added
lots of g_return_if_fail().
* app/base/color-balance.[ch]
* app/base/hue-saturation.[ch]: added init() and reset() functions
so we don't need to duplicate this code in the tool and the pdb
wrappers.
* app/base/curves.[ch]: s/gint/GimpHistogramChannel/g, made
curves_channel_reset() initialize the curves array.
* app/tools/gimpcolorbalancetool.[ch]: use the new functions,
moved the "Range" frame to the top, added a per-range "Reset"
button, made the global "Reset" button reset all ranges and
the "Preserve Luminosity" toggle.
* app/tools/gimpcurvestool.[ch]: don't initialize the curves
array manually, as curves_channel_reset() does that,
s/gint/GimpHistogramChannel/g.
* app/tools/gimphuesaturationtool.c: use the new functions, added
a per-channel "Reset" button and made the global "Reset" button
reset all channels, cleaned up the GUI update function.
* app/tools/gimplevelstool.[ch]: changed to use the new Levels
parameter struct and it's utility functions. Removed stuff
which now lives in base/levels.c
* app/tools/gimpimagemaptool.c: align the "Preview" button
bottom-left, not bottom-right.
* tools/pdbgen/pdb/color.pdb: use the new stuff and removed
uglyness because using the "Levels" struct makes the code more
straightforward.
* app/pdb/color_cmds.c: regenerated.
2002-09-04 23:25:15 +08:00
|
|
|
if (l_tool->levels->low_output[l_tool->channel] != value)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
More color correction stuff cleanup:
2002-09-04 Michael Natterer <mitch@gimp.org>
More color correction stuff cleanup:
* app/base/Makefile.am
* app/base/base-types.h
* app/base/levels.[ch]: new files containing levels_lut_func(), a
new "Levels" parameter struct and the "auto levels" stuff.
* app/base/lut-funcs.[ch]: removed the levels stuff here, added
lots of g_return_if_fail().
* app/base/color-balance.[ch]
* app/base/hue-saturation.[ch]: added init() and reset() functions
so we don't need to duplicate this code in the tool and the pdb
wrappers.
* app/base/curves.[ch]: s/gint/GimpHistogramChannel/g, made
curves_channel_reset() initialize the curves array.
* app/tools/gimpcolorbalancetool.[ch]: use the new functions,
moved the "Range" frame to the top, added a per-range "Reset"
button, made the global "Reset" button reset all ranges and
the "Preserve Luminosity" toggle.
* app/tools/gimpcurvestool.[ch]: don't initialize the curves
array manually, as curves_channel_reset() does that,
s/gint/GimpHistogramChannel/g.
* app/tools/gimphuesaturationtool.c: use the new functions, added
a per-channel "Reset" button and made the global "Reset" button
reset all channels, cleaned up the GUI update function.
* app/tools/gimplevelstool.[ch]: changed to use the new Levels
parameter struct and it's utility functions. Removed stuff
which now lives in base/levels.c
* app/tools/gimpimagemaptool.c: align the "Preview" button
bottom-left, not bottom-right.
* tools/pdbgen/pdb/color.pdb: use the new stuff and removed
uglyness because using the "Levels" struct makes the code more
straightforward.
* app/pdb/color_cmds.c: regenerated.
2002-09-04 23:25:15 +08:00
|
|
|
l_tool->levels->low_output[l_tool->channel] = value;
|
2002-08-26 19:35:56 +08:00
|
|
|
levels_update (l_tool, OUTPUT_LEVELS | OUTPUT_SLIDERS | DRAW);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-08-26 19:35:56 +08:00
|
|
|
gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (l_tool));
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2002-12-18 23:57:25 +08:00
|
|
|
levels_high_output_adjustment_update (GtkAdjustment *adjustment,
|
|
|
|
GimpLevelsTool *l_tool)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2002-12-18 23:57:25 +08:00
|
|
|
gint value;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-11-22 19:14:29 +08:00
|
|
|
value = (gint) (adjustment->value + 0.5);
|
|
|
|
|
More color correction stuff cleanup:
2002-09-04 Michael Natterer <mitch@gimp.org>
More color correction stuff cleanup:
* app/base/Makefile.am
* app/base/base-types.h
* app/base/levels.[ch]: new files containing levels_lut_func(), a
new "Levels" parameter struct and the "auto levels" stuff.
* app/base/lut-funcs.[ch]: removed the levels stuff here, added
lots of g_return_if_fail().
* app/base/color-balance.[ch]
* app/base/hue-saturation.[ch]: added init() and reset() functions
so we don't need to duplicate this code in the tool and the pdb
wrappers.
* app/base/curves.[ch]: s/gint/GimpHistogramChannel/g, made
curves_channel_reset() initialize the curves array.
* app/tools/gimpcolorbalancetool.[ch]: use the new functions,
moved the "Range" frame to the top, added a per-range "Reset"
button, made the global "Reset" button reset all ranges and
the "Preserve Luminosity" toggle.
* app/tools/gimpcurvestool.[ch]: don't initialize the curves
array manually, as curves_channel_reset() does that,
s/gint/GimpHistogramChannel/g.
* app/tools/gimphuesaturationtool.c: use the new functions, added
a per-channel "Reset" button and made the global "Reset" button
reset all channels, cleaned up the GUI update function.
* app/tools/gimplevelstool.[ch]: changed to use the new Levels
parameter struct and it's utility functions. Removed stuff
which now lives in base/levels.c
* app/tools/gimpimagemaptool.c: align the "Preview" button
bottom-left, not bottom-right.
* tools/pdbgen/pdb/color.pdb: use the new stuff and removed
uglyness because using the "Levels" struct makes the code more
straightforward.
* app/pdb/color_cmds.c: regenerated.
2002-09-04 23:25:15 +08:00
|
|
|
if (l_tool->levels->high_output[l_tool->channel] != value)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
More color correction stuff cleanup:
2002-09-04 Michael Natterer <mitch@gimp.org>
More color correction stuff cleanup:
* app/base/Makefile.am
* app/base/base-types.h
* app/base/levels.[ch]: new files containing levels_lut_func(), a
new "Levels" parameter struct and the "auto levels" stuff.
* app/base/lut-funcs.[ch]: removed the levels stuff here, added
lots of g_return_if_fail().
* app/base/color-balance.[ch]
* app/base/hue-saturation.[ch]: added init() and reset() functions
so we don't need to duplicate this code in the tool and the pdb
wrappers.
* app/base/curves.[ch]: s/gint/GimpHistogramChannel/g, made
curves_channel_reset() initialize the curves array.
* app/tools/gimpcolorbalancetool.[ch]: use the new functions,
moved the "Range" frame to the top, added a per-range "Reset"
button, made the global "Reset" button reset all ranges and
the "Preserve Luminosity" toggle.
* app/tools/gimpcurvestool.[ch]: don't initialize the curves
array manually, as curves_channel_reset() does that,
s/gint/GimpHistogramChannel/g.
* app/tools/gimphuesaturationtool.c: use the new functions, added
a per-channel "Reset" button and made the global "Reset" button
reset all channels, cleaned up the GUI update function.
* app/tools/gimplevelstool.[ch]: changed to use the new Levels
parameter struct and it's utility functions. Removed stuff
which now lives in base/levels.c
* app/tools/gimpimagemaptool.c: align the "Preview" button
bottom-left, not bottom-right.
* tools/pdbgen/pdb/color.pdb: use the new stuff and removed
uglyness because using the "Levels" struct makes the code more
straightforward.
* app/pdb/color_cmds.c: regenerated.
2002-09-04 23:25:15 +08:00
|
|
|
l_tool->levels->high_output[l_tool->channel] = value;
|
2002-08-26 19:35:56 +08:00
|
|
|
levels_update (l_tool, OUTPUT_LEVELS | OUTPUT_SLIDERS | DRAW);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-08-26 19:35:56 +08:00
|
|
|
gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (l_tool));
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-10-15 21:36:28 +08:00
|
|
|
static void
|
2002-12-18 23:57:25 +08:00
|
|
|
levels_input_picker_toggled (GtkWidget *widget,
|
2003-03-15 23:02:36 +08:00
|
|
|
GimpLevelsTool *tool)
|
2002-10-15 21:36:28 +08:00
|
|
|
{
|
|
|
|
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)))
|
|
|
|
{
|
2003-03-15 23:02:36 +08:00
|
|
|
if (tool->active_picker == widget)
|
2002-10-15 21:36:28 +08:00
|
|
|
return;
|
|
|
|
|
2003-03-15 23:02:36 +08:00
|
|
|
if (tool->active_picker)
|
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (tool->active_picker),
|
2002-10-15 21:36:28 +08:00
|
|
|
FALSE);
|
|
|
|
|
2003-03-15 23:02:36 +08:00
|
|
|
tool->active_picker = widget;
|
2002-10-15 21:36:28 +08:00
|
|
|
}
|
2003-03-15 23:02:36 +08:00
|
|
|
else if (tool->active_picker == widget)
|
2002-10-15 21:36:28 +08:00
|
|
|
{
|
2003-03-15 23:02:36 +08:00
|
|
|
tool->active_picker = NULL;
|
2002-10-15 21:36:28 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-08-26 19:35:56 +08:00
|
|
|
static gboolean
|
|
|
|
levels_input_da_events (GtkWidget *widget,
|
|
|
|
GdkEvent *event,
|
|
|
|
GimpLevelsTool *l_tool)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
GdkEventButton *bevent;
|
|
|
|
GdkEventMotion *mevent;
|
2002-08-26 19:35:56 +08:00
|
|
|
gchar text[12];
|
|
|
|
gdouble width, mid, tmp;
|
|
|
|
gint x, distance;
|
|
|
|
gint i;
|
|
|
|
gboolean update = FALSE;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
switch (event->type)
|
|
|
|
{
|
|
|
|
case GDK_EXPOSE:
|
2002-08-26 19:35:56 +08:00
|
|
|
if (widget == l_tool->input_levels_da[1])
|
|
|
|
levels_update (l_tool, INPUT_SLIDERS);
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GDK_BUTTON_PRESS:
|
|
|
|
gtk_grab_add (widget);
|
|
|
|
bevent = (GdkEventButton *) event;
|
|
|
|
|
|
|
|
distance = G_MAXINT;
|
|
|
|
for (i = 0; i < 3; i++)
|
2002-08-26 19:35:56 +08:00
|
|
|
if (fabs (bevent->x - l_tool->slider_pos[i]) < distance)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2002-08-26 19:35:56 +08:00
|
|
|
l_tool->active_slider = i;
|
|
|
|
distance = fabs (bevent->x - l_tool->slider_pos[i]);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
x = bevent->x;
|
|
|
|
update = TRUE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GDK_BUTTON_RELEASE:
|
|
|
|
gtk_grab_remove (widget);
|
2002-08-26 19:35:56 +08:00
|
|
|
switch (l_tool->active_slider)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
case 0: /* low input */
|
2002-08-26 19:35:56 +08:00
|
|
|
levels_update (l_tool, LOW_INPUT | GAMMA | DRAW);
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
|
|
|
case 1: /* gamma */
|
2002-08-26 19:35:56 +08:00
|
|
|
levels_update (l_tool, GAMMA);
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
|
|
|
case 2: /* high input */
|
2002-08-26 19:35:56 +08:00
|
|
|
levels_update (l_tool, HIGH_INPUT | GAMMA | DRAW);
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2002-08-26 19:35:56 +08:00
|
|
|
gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (l_tool));
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GDK_MOTION_NOTIFY:
|
|
|
|
mevent = (GdkEventMotion *) event;
|
|
|
|
gdk_window_get_pointer (widget->window, &x, NULL, NULL);
|
|
|
|
update = TRUE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (update)
|
|
|
|
{
|
2002-08-26 19:35:56 +08:00
|
|
|
switch (l_tool->active_slider)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
case 0: /* low input */
|
More color correction stuff cleanup:
2002-09-04 Michael Natterer <mitch@gimp.org>
More color correction stuff cleanup:
* app/base/Makefile.am
* app/base/base-types.h
* app/base/levels.[ch]: new files containing levels_lut_func(), a
new "Levels" parameter struct and the "auto levels" stuff.
* app/base/lut-funcs.[ch]: removed the levels stuff here, added
lots of g_return_if_fail().
* app/base/color-balance.[ch]
* app/base/hue-saturation.[ch]: added init() and reset() functions
so we don't need to duplicate this code in the tool and the pdb
wrappers.
* app/base/curves.[ch]: s/gint/GimpHistogramChannel/g, made
curves_channel_reset() initialize the curves array.
* app/tools/gimpcolorbalancetool.[ch]: use the new functions,
moved the "Range" frame to the top, added a per-range "Reset"
button, made the global "Reset" button reset all ranges and
the "Preserve Luminosity" toggle.
* app/tools/gimpcurvestool.[ch]: don't initialize the curves
array manually, as curves_channel_reset() does that,
s/gint/GimpHistogramChannel/g.
* app/tools/gimphuesaturationtool.c: use the new functions, added
a per-channel "Reset" button and made the global "Reset" button
reset all channels, cleaned up the GUI update function.
* app/tools/gimplevelstool.[ch]: changed to use the new Levels
parameter struct and it's utility functions. Removed stuff
which now lives in base/levels.c
* app/tools/gimpimagemaptool.c: align the "Preview" button
bottom-left, not bottom-right.
* tools/pdbgen/pdb/color.pdb: use the new stuff and removed
uglyness because using the "Levels" struct makes the code more
straightforward.
* app/pdb/color_cmds.c: regenerated.
2002-09-04 23:25:15 +08:00
|
|
|
l_tool->levels->low_input[l_tool->channel] =
|
2002-08-26 19:35:56 +08:00
|
|
|
((gdouble) x / (gdouble) DA_WIDTH) * 255.0;
|
|
|
|
|
More color correction stuff cleanup:
2002-09-04 Michael Natterer <mitch@gimp.org>
More color correction stuff cleanup:
* app/base/Makefile.am
* app/base/base-types.h
* app/base/levels.[ch]: new files containing levels_lut_func(), a
new "Levels" parameter struct and the "auto levels" stuff.
* app/base/lut-funcs.[ch]: removed the levels stuff here, added
lots of g_return_if_fail().
* app/base/color-balance.[ch]
* app/base/hue-saturation.[ch]: added init() and reset() functions
so we don't need to duplicate this code in the tool and the pdb
wrappers.
* app/base/curves.[ch]: s/gint/GimpHistogramChannel/g, made
curves_channel_reset() initialize the curves array.
* app/tools/gimpcolorbalancetool.[ch]: use the new functions,
moved the "Range" frame to the top, added a per-range "Reset"
button, made the global "Reset" button reset all ranges and
the "Preserve Luminosity" toggle.
* app/tools/gimpcurvestool.[ch]: don't initialize the curves
array manually, as curves_channel_reset() does that,
s/gint/GimpHistogramChannel/g.
* app/tools/gimphuesaturationtool.c: use the new functions, added
a per-channel "Reset" button and made the global "Reset" button
reset all channels, cleaned up the GUI update function.
* app/tools/gimplevelstool.[ch]: changed to use the new Levels
parameter struct and it's utility functions. Removed stuff
which now lives in base/levels.c
* app/tools/gimpimagemaptool.c: align the "Preview" button
bottom-left, not bottom-right.
* tools/pdbgen/pdb/color.pdb: use the new stuff and removed
uglyness because using the "Levels" struct makes the code more
straightforward.
* app/pdb/color_cmds.c: regenerated.
2002-09-04 23:25:15 +08:00
|
|
|
l_tool->levels->low_input[l_tool->channel] =
|
|
|
|
CLAMP (l_tool->levels->low_input[l_tool->channel],
|
|
|
|
0, l_tool->levels->high_input[l_tool->channel]);
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 1: /* gamma */
|
2002-08-26 19:35:56 +08:00
|
|
|
width = (double) (l_tool->slider_pos[2] - l_tool->slider_pos[0]) / 2.0;
|
|
|
|
mid = l_tool->slider_pos[0] + width;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-08-26 19:35:56 +08:00
|
|
|
x = CLAMP (x, l_tool->slider_pos[0], l_tool->slider_pos[2]);
|
1997-11-25 06:05:25 +08:00
|
|
|
tmp = (double) (x - mid) / width;
|
2002-08-26 19:35:56 +08:00
|
|
|
|
More color correction stuff cleanup:
2002-09-04 Michael Natterer <mitch@gimp.org>
More color correction stuff cleanup:
* app/base/Makefile.am
* app/base/base-types.h
* app/base/levels.[ch]: new files containing levels_lut_func(), a
new "Levels" parameter struct and the "auto levels" stuff.
* app/base/lut-funcs.[ch]: removed the levels stuff here, added
lots of g_return_if_fail().
* app/base/color-balance.[ch]
* app/base/hue-saturation.[ch]: added init() and reset() functions
so we don't need to duplicate this code in the tool and the pdb
wrappers.
* app/base/curves.[ch]: s/gint/GimpHistogramChannel/g, made
curves_channel_reset() initialize the curves array.
* app/tools/gimpcolorbalancetool.[ch]: use the new functions,
moved the "Range" frame to the top, added a per-range "Reset"
button, made the global "Reset" button reset all ranges and
the "Preserve Luminosity" toggle.
* app/tools/gimpcurvestool.[ch]: don't initialize the curves
array manually, as curves_channel_reset() does that,
s/gint/GimpHistogramChannel/g.
* app/tools/gimphuesaturationtool.c: use the new functions, added
a per-channel "Reset" button and made the global "Reset" button
reset all channels, cleaned up the GUI update function.
* app/tools/gimplevelstool.[ch]: changed to use the new Levels
parameter struct and it's utility functions. Removed stuff
which now lives in base/levels.c
* app/tools/gimpimagemaptool.c: align the "Preview" button
bottom-left, not bottom-right.
* tools/pdbgen/pdb/color.pdb: use the new stuff and removed
uglyness because using the "Levels" struct makes the code more
straightforward.
* app/pdb/color_cmds.c: regenerated.
2002-09-04 23:25:15 +08:00
|
|
|
l_tool->levels->gamma[l_tool->channel] = 1.0 / pow (10, tmp);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* round the gamma value to the nearest 1/100th */
|
More color correction stuff cleanup:
2002-09-04 Michael Natterer <mitch@gimp.org>
More color correction stuff cleanup:
* app/base/Makefile.am
* app/base/base-types.h
* app/base/levels.[ch]: new files containing levels_lut_func(), a
new "Levels" parameter struct and the "auto levels" stuff.
* app/base/lut-funcs.[ch]: removed the levels stuff here, added
lots of g_return_if_fail().
* app/base/color-balance.[ch]
* app/base/hue-saturation.[ch]: added init() and reset() functions
so we don't need to duplicate this code in the tool and the pdb
wrappers.
* app/base/curves.[ch]: s/gint/GimpHistogramChannel/g, made
curves_channel_reset() initialize the curves array.
* app/tools/gimpcolorbalancetool.[ch]: use the new functions,
moved the "Range" frame to the top, added a per-range "Reset"
button, made the global "Reset" button reset all ranges and
the "Preserve Luminosity" toggle.
* app/tools/gimpcurvestool.[ch]: don't initialize the curves
array manually, as curves_channel_reset() does that,
s/gint/GimpHistogramChannel/g.
* app/tools/gimphuesaturationtool.c: use the new functions, added
a per-channel "Reset" button and made the global "Reset" button
reset all channels, cleaned up the GUI update function.
* app/tools/gimplevelstool.[ch]: changed to use the new Levels
parameter struct and it's utility functions. Removed stuff
which now lives in base/levels.c
* app/tools/gimpimagemaptool.c: align the "Preview" button
bottom-left, not bottom-right.
* tools/pdbgen/pdb/color.pdb: use the new stuff and removed
uglyness because using the "Levels" struct makes the code more
straightforward.
* app/pdb/color_cmds.c: regenerated.
2002-09-04 23:25:15 +08:00
|
|
|
sprintf (text, "%2.2f", l_tool->levels->gamma[l_tool->channel]);
|
|
|
|
l_tool->levels->gamma[l_tool->channel] = atof (text);
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 2: /* high input */
|
More color correction stuff cleanup:
2002-09-04 Michael Natterer <mitch@gimp.org>
More color correction stuff cleanup:
* app/base/Makefile.am
* app/base/base-types.h
* app/base/levels.[ch]: new files containing levels_lut_func(), a
new "Levels" parameter struct and the "auto levels" stuff.
* app/base/lut-funcs.[ch]: removed the levels stuff here, added
lots of g_return_if_fail().
* app/base/color-balance.[ch]
* app/base/hue-saturation.[ch]: added init() and reset() functions
so we don't need to duplicate this code in the tool and the pdb
wrappers.
* app/base/curves.[ch]: s/gint/GimpHistogramChannel/g, made
curves_channel_reset() initialize the curves array.
* app/tools/gimpcolorbalancetool.[ch]: use the new functions,
moved the "Range" frame to the top, added a per-range "Reset"
button, made the global "Reset" button reset all ranges and
the "Preserve Luminosity" toggle.
* app/tools/gimpcurvestool.[ch]: don't initialize the curves
array manually, as curves_channel_reset() does that,
s/gint/GimpHistogramChannel/g.
* app/tools/gimphuesaturationtool.c: use the new functions, added
a per-channel "Reset" button and made the global "Reset" button
reset all channels, cleaned up the GUI update function.
* app/tools/gimplevelstool.[ch]: changed to use the new Levels
parameter struct and it's utility functions. Removed stuff
which now lives in base/levels.c
* app/tools/gimpimagemaptool.c: align the "Preview" button
bottom-left, not bottom-right.
* tools/pdbgen/pdb/color.pdb: use the new stuff and removed
uglyness because using the "Levels" struct makes the code more
straightforward.
* app/pdb/color_cmds.c: regenerated.
2002-09-04 23:25:15 +08:00
|
|
|
l_tool->levels->high_input[l_tool->channel] =
|
2002-08-26 19:35:56 +08:00
|
|
|
((gdouble) x / (gdouble) DA_WIDTH) * 255.0;
|
|
|
|
|
More color correction stuff cleanup:
2002-09-04 Michael Natterer <mitch@gimp.org>
More color correction stuff cleanup:
* app/base/Makefile.am
* app/base/base-types.h
* app/base/levels.[ch]: new files containing levels_lut_func(), a
new "Levels" parameter struct and the "auto levels" stuff.
* app/base/lut-funcs.[ch]: removed the levels stuff here, added
lots of g_return_if_fail().
* app/base/color-balance.[ch]
* app/base/hue-saturation.[ch]: added init() and reset() functions
so we don't need to duplicate this code in the tool and the pdb
wrappers.
* app/base/curves.[ch]: s/gint/GimpHistogramChannel/g, made
curves_channel_reset() initialize the curves array.
* app/tools/gimpcolorbalancetool.[ch]: use the new functions,
moved the "Range" frame to the top, added a per-range "Reset"
button, made the global "Reset" button reset all ranges and
the "Preserve Luminosity" toggle.
* app/tools/gimpcurvestool.[ch]: don't initialize the curves
array manually, as curves_channel_reset() does that,
s/gint/GimpHistogramChannel/g.
* app/tools/gimphuesaturationtool.c: use the new functions, added
a per-channel "Reset" button and made the global "Reset" button
reset all channels, cleaned up the GUI update function.
* app/tools/gimplevelstool.[ch]: changed to use the new Levels
parameter struct and it's utility functions. Removed stuff
which now lives in base/levels.c
* app/tools/gimpimagemaptool.c: align the "Preview" button
bottom-left, not bottom-right.
* tools/pdbgen/pdb/color.pdb: use the new stuff and removed
uglyness because using the "Levels" struct makes the code more
straightforward.
* app/pdb/color_cmds.c: regenerated.
2002-09-04 23:25:15 +08:00
|
|
|
l_tool->levels->high_input[l_tool->channel] =
|
|
|
|
CLAMP (l_tool->levels->high_input[l_tool->channel],
|
|
|
|
l_tool->levels->low_input[l_tool->channel], 255);
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2002-08-26 19:35:56 +08:00
|
|
|
levels_update (l_tool, INPUT_SLIDERS | INPUT_LEVELS | DRAW);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2002-08-26 19:35:56 +08:00
|
|
|
static gboolean
|
|
|
|
levels_output_da_events (GtkWidget *widget,
|
|
|
|
GdkEvent *event,
|
|
|
|
GimpLevelsTool *l_tool)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
GdkEventButton *bevent;
|
|
|
|
GdkEventMotion *mevent;
|
2002-08-26 19:35:56 +08:00
|
|
|
gint x, distance;
|
|
|
|
gint i;
|
|
|
|
gboolean update = FALSE;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
switch (event->type)
|
|
|
|
{
|
|
|
|
case GDK_EXPOSE:
|
2002-08-26 19:35:56 +08:00
|
|
|
if (widget == l_tool->output_levels_da[1])
|
|
|
|
levels_update (l_tool, OUTPUT_SLIDERS);
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GDK_BUTTON_PRESS:
|
|
|
|
bevent = (GdkEventButton *) event;
|
|
|
|
|
|
|
|
distance = G_MAXINT;
|
|
|
|
for (i = 3; i < 5; i++)
|
2002-08-26 19:35:56 +08:00
|
|
|
if (fabs (bevent->x - l_tool->slider_pos[i]) < distance)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2002-08-26 19:35:56 +08:00
|
|
|
l_tool->active_slider = i;
|
|
|
|
distance = fabs (bevent->x - l_tool->slider_pos[i]);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
x = bevent->x;
|
|
|
|
update = TRUE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GDK_BUTTON_RELEASE:
|
2002-08-26 19:35:56 +08:00
|
|
|
switch (l_tool->active_slider)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
case 3: /* low output */
|
2002-08-26 19:35:56 +08:00
|
|
|
levels_update (l_tool, LOW_OUTPUT | DRAW);
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
|
|
|
case 4: /* high output */
|
2002-08-26 19:35:56 +08:00
|
|
|
levels_update (l_tool, HIGH_OUTPUT | DRAW);
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2002-08-26 19:35:56 +08:00
|
|
|
gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (l_tool));
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GDK_MOTION_NOTIFY:
|
|
|
|
mevent = (GdkEventMotion *) event;
|
|
|
|
gdk_window_get_pointer (widget->window, &x, NULL, NULL);
|
|
|
|
update = TRUE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (update)
|
|
|
|
{
|
2002-08-26 19:35:56 +08:00
|
|
|
switch (l_tool->active_slider)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
case 3: /* low output */
|
More color correction stuff cleanup:
2002-09-04 Michael Natterer <mitch@gimp.org>
More color correction stuff cleanup:
* app/base/Makefile.am
* app/base/base-types.h
* app/base/levels.[ch]: new files containing levels_lut_func(), a
new "Levels" parameter struct and the "auto levels" stuff.
* app/base/lut-funcs.[ch]: removed the levels stuff here, added
lots of g_return_if_fail().
* app/base/color-balance.[ch]
* app/base/hue-saturation.[ch]: added init() and reset() functions
so we don't need to duplicate this code in the tool and the pdb
wrappers.
* app/base/curves.[ch]: s/gint/GimpHistogramChannel/g, made
curves_channel_reset() initialize the curves array.
* app/tools/gimpcolorbalancetool.[ch]: use the new functions,
moved the "Range" frame to the top, added a per-range "Reset"
button, made the global "Reset" button reset all ranges and
the "Preserve Luminosity" toggle.
* app/tools/gimpcurvestool.[ch]: don't initialize the curves
array manually, as curves_channel_reset() does that,
s/gint/GimpHistogramChannel/g.
* app/tools/gimphuesaturationtool.c: use the new functions, added
a per-channel "Reset" button and made the global "Reset" button
reset all channels, cleaned up the GUI update function.
* app/tools/gimplevelstool.[ch]: changed to use the new Levels
parameter struct and it's utility functions. Removed stuff
which now lives in base/levels.c
* app/tools/gimpimagemaptool.c: align the "Preview" button
bottom-left, not bottom-right.
* tools/pdbgen/pdb/color.pdb: use the new stuff and removed
uglyness because using the "Levels" struct makes the code more
straightforward.
* app/pdb/color_cmds.c: regenerated.
2002-09-04 23:25:15 +08:00
|
|
|
l_tool->levels->low_output[l_tool->channel] =
|
2002-08-26 19:35:56 +08:00
|
|
|
((gdouble) x / (gdouble) DA_WIDTH) * 255.0;
|
|
|
|
|
More color correction stuff cleanup:
2002-09-04 Michael Natterer <mitch@gimp.org>
More color correction stuff cleanup:
* app/base/Makefile.am
* app/base/base-types.h
* app/base/levels.[ch]: new files containing levels_lut_func(), a
new "Levels" parameter struct and the "auto levels" stuff.
* app/base/lut-funcs.[ch]: removed the levels stuff here, added
lots of g_return_if_fail().
* app/base/color-balance.[ch]
* app/base/hue-saturation.[ch]: added init() and reset() functions
so we don't need to duplicate this code in the tool and the pdb
wrappers.
* app/base/curves.[ch]: s/gint/GimpHistogramChannel/g, made
curves_channel_reset() initialize the curves array.
* app/tools/gimpcolorbalancetool.[ch]: use the new functions,
moved the "Range" frame to the top, added a per-range "Reset"
button, made the global "Reset" button reset all ranges and
the "Preserve Luminosity" toggle.
* app/tools/gimpcurvestool.[ch]: don't initialize the curves
array manually, as curves_channel_reset() does that,
s/gint/GimpHistogramChannel/g.
* app/tools/gimphuesaturationtool.c: use the new functions, added
a per-channel "Reset" button and made the global "Reset" button
reset all channels, cleaned up the GUI update function.
* app/tools/gimplevelstool.[ch]: changed to use the new Levels
parameter struct and it's utility functions. Removed stuff
which now lives in base/levels.c
* app/tools/gimpimagemaptool.c: align the "Preview" button
bottom-left, not bottom-right.
* tools/pdbgen/pdb/color.pdb: use the new stuff and removed
uglyness because using the "Levels" struct makes the code more
straightforward.
* app/pdb/color_cmds.c: regenerated.
2002-09-04 23:25:15 +08:00
|
|
|
l_tool->levels->low_output[l_tool->channel] =
|
|
|
|
CLAMP (l_tool->levels->low_output[l_tool->channel], 0, 255);
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 4: /* high output */
|
More color correction stuff cleanup:
2002-09-04 Michael Natterer <mitch@gimp.org>
More color correction stuff cleanup:
* app/base/Makefile.am
* app/base/base-types.h
* app/base/levels.[ch]: new files containing levels_lut_func(), a
new "Levels" parameter struct and the "auto levels" stuff.
* app/base/lut-funcs.[ch]: removed the levels stuff here, added
lots of g_return_if_fail().
* app/base/color-balance.[ch]
* app/base/hue-saturation.[ch]: added init() and reset() functions
so we don't need to duplicate this code in the tool and the pdb
wrappers.
* app/base/curves.[ch]: s/gint/GimpHistogramChannel/g, made
curves_channel_reset() initialize the curves array.
* app/tools/gimpcolorbalancetool.[ch]: use the new functions,
moved the "Range" frame to the top, added a per-range "Reset"
button, made the global "Reset" button reset all ranges and
the "Preserve Luminosity" toggle.
* app/tools/gimpcurvestool.[ch]: don't initialize the curves
array manually, as curves_channel_reset() does that,
s/gint/GimpHistogramChannel/g.
* app/tools/gimphuesaturationtool.c: use the new functions, added
a per-channel "Reset" button and made the global "Reset" button
reset all channels, cleaned up the GUI update function.
* app/tools/gimplevelstool.[ch]: changed to use the new Levels
parameter struct and it's utility functions. Removed stuff
which now lives in base/levels.c
* app/tools/gimpimagemaptool.c: align the "Preview" button
bottom-left, not bottom-right.
* tools/pdbgen/pdb/color.pdb: use the new stuff and removed
uglyness because using the "Levels" struct makes the code more
straightforward.
* app/pdb/color_cmds.c: regenerated.
2002-09-04 23:25:15 +08:00
|
|
|
l_tool->levels->high_output[l_tool->channel] =
|
2002-08-26 19:35:56 +08:00
|
|
|
((gdouble) x / (gdouble) DA_WIDTH) * 255.0;
|
|
|
|
|
More color correction stuff cleanup:
2002-09-04 Michael Natterer <mitch@gimp.org>
More color correction stuff cleanup:
* app/base/Makefile.am
* app/base/base-types.h
* app/base/levels.[ch]: new files containing levels_lut_func(), a
new "Levels" parameter struct and the "auto levels" stuff.
* app/base/lut-funcs.[ch]: removed the levels stuff here, added
lots of g_return_if_fail().
* app/base/color-balance.[ch]
* app/base/hue-saturation.[ch]: added init() and reset() functions
so we don't need to duplicate this code in the tool and the pdb
wrappers.
* app/base/curves.[ch]: s/gint/GimpHistogramChannel/g, made
curves_channel_reset() initialize the curves array.
* app/tools/gimpcolorbalancetool.[ch]: use the new functions,
moved the "Range" frame to the top, added a per-range "Reset"
button, made the global "Reset" button reset all ranges and
the "Preserve Luminosity" toggle.
* app/tools/gimpcurvestool.[ch]: don't initialize the curves
array manually, as curves_channel_reset() does that,
s/gint/GimpHistogramChannel/g.
* app/tools/gimphuesaturationtool.c: use the new functions, added
a per-channel "Reset" button and made the global "Reset" button
reset all channels, cleaned up the GUI update function.
* app/tools/gimplevelstool.[ch]: changed to use the new Levels
parameter struct and it's utility functions. Removed stuff
which now lives in base/levels.c
* app/tools/gimpimagemaptool.c: align the "Preview" button
bottom-left, not bottom-right.
* tools/pdbgen/pdb/color.pdb: use the new stuff and removed
uglyness because using the "Levels" struct makes the code more
straightforward.
* app/pdb/color_cmds.c: regenerated.
2002-09-04 23:25:15 +08:00
|
|
|
l_tool->levels->high_output[l_tool->channel] =
|
|
|
|
CLAMP (l_tool->levels->high_output[l_tool->channel], 0, 255);
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2002-08-26 19:35:56 +08:00
|
|
|
levels_update (l_tool, OUTPUT_SLIDERS | DRAW);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
1999-08-27 08:19:25 +08:00
|
|
|
|
2003-03-17 01:00:40 +08:00
|
|
|
static void
|
|
|
|
levels_input_adjust_by_color (Levels *levels,
|
|
|
|
guint value,
|
|
|
|
GimpHistogramChannel channel,
|
|
|
|
guchar *color)
|
|
|
|
{
|
|
|
|
switch (value & 0xF)
|
|
|
|
{
|
|
|
|
case LOW_INPUT:
|
|
|
|
levels_adjust_by_colors (levels, channel, color, NULL, NULL);
|
|
|
|
break;
|
|
|
|
case GAMMA:
|
|
|
|
levels_adjust_by_colors (levels, channel, NULL, color, NULL);
|
|
|
|
break;
|
|
|
|
case HIGH_INPUT:
|
|
|
|
levels_adjust_by_colors (levels, channel, NULL, NULL, color);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-03-15 23:02:36 +08:00
|
|
|
static void
|
|
|
|
levels_input_color_pick (GimpTool *tool,
|
|
|
|
GimpDrawable *drawable,
|
|
|
|
GimpCoords *coords)
|
|
|
|
{
|
|
|
|
GimpLevelsTool *l_tool;
|
|
|
|
guchar *color;
|
|
|
|
guint value;
|
2003-03-17 01:00:40 +08:00
|
|
|
gint x, y;
|
2003-03-15 23:02:36 +08:00
|
|
|
|
|
|
|
l_tool = GIMP_LEVELS_TOOL (tool);
|
|
|
|
|
|
|
|
if (! l_tool->active_picker || !drawable)
|
|
|
|
return;
|
|
|
|
|
|
|
|
gimp_drawable_offsets (drawable, &x, &y);
|
|
|
|
|
|
|
|
x = RINT (coords->x) - x;
|
|
|
|
y = RINT (coords->y) - y;
|
|
|
|
|
|
|
|
color = gimp_image_map_get_color_at (GIMP_IMAGE_MAP_TOOL (tool)->image_map,
|
|
|
|
x, y);
|
|
|
|
if (!color)
|
|
|
|
return;
|
|
|
|
|
|
|
|
value = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (l_tool->active_picker),
|
|
|
|
"pick_value"));
|
|
|
|
|
2003-03-17 01:00:40 +08:00
|
|
|
if (value & ALL_CHANNELS && GIMP_IMAGE_TYPE_IS_RGB (drawable->type))
|
2003-03-15 23:02:36 +08:00
|
|
|
{
|
2003-03-17 01:00:40 +08:00
|
|
|
GimpHistogramChannel channel;
|
|
|
|
|
|
|
|
/* first reset the value channel */
|
|
|
|
switch (value & 0xF)
|
|
|
|
{
|
|
|
|
case LOW_INPUT:
|
|
|
|
l_tool->levels->low_input[GIMP_HISTOGRAM_VALUE] = 0;
|
|
|
|
break;
|
|
|
|
case GAMMA:
|
|
|
|
l_tool->levels->gamma[GIMP_HISTOGRAM_VALUE] = 1.0;
|
|
|
|
break;
|
|
|
|
case HIGH_INPUT:
|
|
|
|
l_tool->levels->high_input[GIMP_HISTOGRAM_VALUE] = 255;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* then adjust all color channels */
|
|
|
|
for (channel = GIMP_HISTOGRAM_RED;
|
|
|
|
channel <= GIMP_HISTOGRAM_BLUE;
|
|
|
|
channel++)
|
|
|
|
{
|
|
|
|
levels_input_adjust_by_color (l_tool->levels, value, channel, color);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
levels_input_adjust_by_color (l_tool->levels,
|
|
|
|
value, l_tool->channel, color);
|
2003-03-15 23:02:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
levels_update (l_tool, ALL);
|
|
|
|
|
|
|
|
gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (l_tool));
|
|
|
|
|
|
|
|
g_free (color);
|
|
|
|
}
|
|
|
|
|
1999-08-27 08:19:25 +08:00
|
|
|
static void
|
2002-12-18 23:57:25 +08:00
|
|
|
levels_load_callback (GtkWidget *widget,
|
|
|
|
GimpLevelsTool *l_tool)
|
2002-08-26 19:35:56 +08:00
|
|
|
{
|
|
|
|
if (! l_tool->file_dialog)
|
|
|
|
file_dialog_create (l_tool);
|
|
|
|
else if (GTK_WIDGET_VISIBLE (l_tool->file_dialog))
|
|
|
|
return;
|
|
|
|
|
|
|
|
l_tool->is_save = FALSE;
|
|
|
|
|
|
|
|
gtk_window_set_title (GTK_WINDOW (l_tool->file_dialog), _("Load Levels"));
|
|
|
|
gtk_widget_show (l_tool->file_dialog);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2002-12-18 23:57:25 +08:00
|
|
|
levels_save_callback (GtkWidget *widget,
|
|
|
|
GimpLevelsTool *l_tool)
|
1999-08-27 08:19:25 +08:00
|
|
|
{
|
2002-08-26 19:35:56 +08:00
|
|
|
if (! l_tool->file_dialog)
|
|
|
|
file_dialog_create (l_tool);
|
|
|
|
else if (GTK_WIDGET_VISIBLE (l_tool->file_dialog))
|
|
|
|
return;
|
|
|
|
|
|
|
|
l_tool->is_save = TRUE;
|
|
|
|
|
|
|
|
gtk_window_set_title (GTK_WINDOW (l_tool->file_dialog), _("Save Levels"));
|
|
|
|
gtk_widget_show (l_tool->file_dialog);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
file_dialog_create (GimpLevelsTool *l_tool)
|
|
|
|
{
|
|
|
|
GtkFileSelection *file_dlg;
|
|
|
|
gchar *temp;
|
|
|
|
|
|
|
|
l_tool->file_dialog = gtk_file_selection_new ("");
|
|
|
|
|
|
|
|
file_dlg = GTK_FILE_SELECTION (l_tool->file_dialog);
|
1999-08-28 05:06:00 +08:00
|
|
|
|
1999-12-31 04:16:58 +08:00
|
|
|
gtk_window_set_wmclass (GTK_WINDOW (file_dlg), "load_save_levels", "Gimp");
|
1999-12-18 00:37:50 +08:00
|
|
|
gtk_window_set_position (GTK_WINDOW (file_dlg), GTK_WIN_POS_MOUSE);
|
1999-11-22 19:14:29 +08:00
|
|
|
|
1999-12-31 04:16:58 +08:00
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (file_dlg), 2);
|
2002-08-26 19:35:56 +08:00
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (file_dlg->button_area), 2);
|
|
|
|
|
2002-10-14 21:39:35 +08:00
|
|
|
g_object_add_weak_pointer (G_OBJECT (file_dlg),
|
|
|
|
(gpointer) &l_tool->file_dialog);
|
|
|
|
|
|
|
|
gtk_window_set_transient_for (GTK_WINDOW (file_dlg),
|
|
|
|
GTK_WINDOW (GIMP_IMAGE_MAP_TOOL (l_tool)->shell));
|
|
|
|
gtk_window_set_destroy_with_parent (GTK_WINDOW (file_dlg), TRUE);
|
|
|
|
|
2003-01-06 06:07:10 +08:00
|
|
|
g_signal_connect_swapped (file_dlg->ok_button, "clicked",
|
2002-08-26 19:35:56 +08:00
|
|
|
G_CALLBACK (file_dialog_ok_callback),
|
|
|
|
l_tool);
|
2003-01-06 06:07:10 +08:00
|
|
|
g_signal_connect_swapped (file_dlg->cancel_button, "clicked",
|
2002-10-14 21:39:35 +08:00
|
|
|
G_CALLBACK (gtk_widget_destroy),
|
|
|
|
file_dlg);
|
2002-08-26 19:35:56 +08:00
|
|
|
|
2002-10-14 21:39:35 +08:00
|
|
|
temp = g_build_filename (gimp_directory (), "levels", ".", NULL);
|
2002-08-26 19:35:56 +08:00
|
|
|
gtk_file_selection_set_filename (file_dlg, temp);
|
1999-08-28 05:06:00 +08:00
|
|
|
g_free (temp);
|
2000-02-14 06:26:41 +08:00
|
|
|
|
2002-08-26 19:35:56 +08:00
|
|
|
gimp_help_connect (l_tool->file_dialog, tool_manager_help_func, NULL);
|
1999-08-27 08:19:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2002-08-26 19:35:56 +08:00
|
|
|
file_dialog_ok_callback (GimpLevelsTool *l_tool)
|
1999-08-27 08:19:25 +08:00
|
|
|
{
|
2002-08-26 19:35:56 +08:00
|
|
|
FILE *file = NULL;
|
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
2001-07-24 Michael Natterer <mitch@gimp.org>
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
* configure.in: require glib/gtk+ >= 1.3.7, commented out the
gtkxmhtml stuff.
From now on, you will need glib, pango, atk and gtk+ HEAD from CVS
to hack or use GIMP HEAD.
Beware, it crashes randomly :)
* app/core/Makefile.am
* app/core/gimpmarshal.list: new file plus rules to generate
gimpmarshal.[ch] from it.
* app/core/*
* app/tools/*
* app/widgets/*
* libgimpwidgets/*: started to use the glib object system. All
core/ objects are still gtk objects however. All signals are
created using g_signal_new(). There are many gtk+ artefacts left.
Finally, we will _not_ use the gtk_signal_foo() wrappers and
friends any more.
* app/colormaps.c
* app/devices.[ch]
* app/disp_callbacks.c
* app/errorconsole.c
* app/file-save.[ch]
* app/interface.c
* app/module_db.c
* app/nav_window.c
* app/ops_buttons.c
* app/scroll.c
* app/user_install.c
* app/gui/about-dialog.c
* app/gui/brush-editor.c
* app/gui/brushes-commands.c
* app/gui/color-notebook.c
* app/gui/colormap-dialog.c
* app/gui/dialogs-commands.c
* app/gui/dialogs-constructors.c
* app/gui/file-commands.c
* app/gui/file-dialog-utils.c
* app/gui/file-new-dialog.c
* app/gui/file-open-dialog.[ch]
* app/gui/file-save-dialog.c
* app/gui/gradient-editor.c
* app/gui/gradients-commands.c
* app/gui/image-commands.c
* app/gui/info-dialog.[ch]
* app/gui/layer-select.c
* app/gui/layers-commands.c
* app/gui/menus.c
* app/gui/offset-dialog.c
* app/gui/palette-editor.c
* app/gui/palettes-commands.c
* app/gui/patterns-commands.c
* app/gui/preferences-dialog.c
* app/gui/resize-dialog.[ch]
* app/gui/splash.c
* app/gui/tips-dialog.c
* app/gui/tool-options-dialog.c
* app/gui/toolbox.c
* app/gui/tools-commands.c
* libgimp/gimpbrushmenu.c
* libgimp/gimpmenu.c
* libgimp/gimppatternmenu.c
* libgimp/gimpui.c
* libgimpbase/gimpenv.c: tons and tons of changes like "const
gchar*", switch from GdkDeviceInfo to GdkDevice (very incomplete
and currently disables), lots of s/gtk_signal/g_signal/,
removal/replacement of deprecated stuff,
s/GtkSignalFunc/GCallback/ and lots of small changes and fixes
while I was on it, zillions of warnings left...
* modules/Makefile.am: disabled the water color selector
temporarily (XInput issues).
* plug-ins/Makefile.am
* plug-ins/common/.cvsignore
* plug-ins/common/Makefile.am
* plug-ins/common/plugin-defs.pl: simply excluded all plug-ins
which did not build (including Script-Fu). They are trivial to
fix.
2001-07-25 05:27:11 +08:00
|
|
|
const gchar *filename;
|
1999-08-27 08:19:25 +08:00
|
|
|
|
2002-08-26 19:35:56 +08:00
|
|
|
filename =
|
|
|
|
gtk_file_selection_get_filename (GTK_FILE_SELECTION (l_tool->file_dialog));
|
1999-08-27 08:19:25 +08:00
|
|
|
|
2002-10-15 21:36:28 +08:00
|
|
|
file = fopen (filename, l_tool->is_save ? "wt" : "rt");
|
1999-08-27 08:19:25 +08:00
|
|
|
|
2002-10-15 21:36:28 +08:00
|
|
|
if (! file)
|
1999-08-27 08:19:25 +08:00
|
|
|
{
|
2002-10-15 21:36:28 +08:00
|
|
|
g_message (_("Failed to open file: '%s': %s"),
|
|
|
|
filename, g_strerror (errno));
|
|
|
|
return;
|
|
|
|
}
|
1999-08-27 08:19:25 +08:00
|
|
|
|
2002-10-15 21:36:28 +08:00
|
|
|
if (l_tool->is_save)
|
|
|
|
{
|
2002-08-26 19:35:56 +08:00
|
|
|
levels_write_to_file (l_tool, file);
|
1999-08-27 08:19:25 +08:00
|
|
|
}
|
2002-10-15 21:36:28 +08:00
|
|
|
else if (! levels_read_from_file (l_tool, file))
|
|
|
|
{
|
|
|
|
g_message (("Error in reading file '%s'."), filename);
|
|
|
|
}
|
2002-08-26 19:35:56 +08:00
|
|
|
|
|
|
|
if (file)
|
|
|
|
fclose (file);
|
|
|
|
|
2002-10-14 21:39:35 +08:00
|
|
|
gtk_widget_destroy (l_tool->file_dialog);
|
1999-08-27 08:19:25 +08:00
|
|
|
}
|
|
|
|
|
1999-11-22 19:14:29 +08:00
|
|
|
static gboolean
|
2002-08-26 19:35:56 +08:00
|
|
|
levels_read_from_file (GimpLevelsTool *l_tool,
|
|
|
|
FILE *file)
|
1999-08-27 08:19:25 +08:00
|
|
|
{
|
2002-08-26 19:35:56 +08:00
|
|
|
gint low_input[5];
|
|
|
|
gint high_input[5];
|
|
|
|
gint low_output[5];
|
|
|
|
gint high_output[5];
|
|
|
|
gdouble gamma[5];
|
|
|
|
gint i, fields;
|
|
|
|
gchar buf[50], *nptr;
|
1999-08-27 08:19:25 +08:00
|
|
|
|
2002-08-26 19:35:56 +08:00
|
|
|
if (! fgets (buf, 50, file))
|
1999-08-28 06:02:18 +08:00
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (strcmp (buf, "# GIMP Levels File\n") != 0)
|
|
|
|
return FALSE;
|
|
|
|
|
1999-08-27 08:19:25 +08:00
|
|
|
for (i = 0; i < 5; i++)
|
|
|
|
{
|
2002-08-26 19:35:56 +08:00
|
|
|
fields = fscanf (file, "%d %d %d %d ",
|
1999-08-27 08:19:25 +08:00
|
|
|
&low_input[i],
|
|
|
|
&high_input[i],
|
|
|
|
&low_output[i],
|
|
|
|
&high_output[i]);
|
|
|
|
|
1999-08-28 06:02:18 +08:00
|
|
|
if (fields != 4)
|
|
|
|
return FALSE;
|
|
|
|
|
2002-08-26 19:35:56 +08:00
|
|
|
if (! fgets (buf, 50, file))
|
1999-08-27 08:19:25 +08:00
|
|
|
return FALSE;
|
|
|
|
|
2001-10-29 20:51:21 +08:00
|
|
|
gamma[i] = g_ascii_strtod (buf, &nptr);
|
1999-08-27 08:19:25 +08:00
|
|
|
|
|
|
|
if (buf == nptr || errno == ERANGE)
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < 5; i++)
|
|
|
|
{
|
More color correction stuff cleanup:
2002-09-04 Michael Natterer <mitch@gimp.org>
More color correction stuff cleanup:
* app/base/Makefile.am
* app/base/base-types.h
* app/base/levels.[ch]: new files containing levels_lut_func(), a
new "Levels" parameter struct and the "auto levels" stuff.
* app/base/lut-funcs.[ch]: removed the levels stuff here, added
lots of g_return_if_fail().
* app/base/color-balance.[ch]
* app/base/hue-saturation.[ch]: added init() and reset() functions
so we don't need to duplicate this code in the tool and the pdb
wrappers.
* app/base/curves.[ch]: s/gint/GimpHistogramChannel/g, made
curves_channel_reset() initialize the curves array.
* app/tools/gimpcolorbalancetool.[ch]: use the new functions,
moved the "Range" frame to the top, added a per-range "Reset"
button, made the global "Reset" button reset all ranges and
the "Preserve Luminosity" toggle.
* app/tools/gimpcurvestool.[ch]: don't initialize the curves
array manually, as curves_channel_reset() does that,
s/gint/GimpHistogramChannel/g.
* app/tools/gimphuesaturationtool.c: use the new functions, added
a per-channel "Reset" button and made the global "Reset" button
reset all channels, cleaned up the GUI update function.
* app/tools/gimplevelstool.[ch]: changed to use the new Levels
parameter struct and it's utility functions. Removed stuff
which now lives in base/levels.c
* app/tools/gimpimagemaptool.c: align the "Preview" button
bottom-left, not bottom-right.
* tools/pdbgen/pdb/color.pdb: use the new stuff and removed
uglyness because using the "Levels" struct makes the code more
straightforward.
* app/pdb/color_cmds.c: regenerated.
2002-09-04 23:25:15 +08:00
|
|
|
l_tool->levels->low_input[i] = low_input[i];
|
|
|
|
l_tool->levels->high_input[i] = high_input[i];
|
|
|
|
l_tool->levels->low_output[i] = low_output[i];
|
|
|
|
l_tool->levels->high_output[i] = high_output[i];
|
|
|
|
l_tool->levels->gamma[i] = gamma[i];
|
1999-08-27 08:19:25 +08:00
|
|
|
}
|
|
|
|
|
2002-08-26 19:35:56 +08:00
|
|
|
levels_update (l_tool, ALL);
|
1999-11-22 19:14:29 +08:00
|
|
|
|
2002-08-26 19:35:56 +08:00
|
|
|
gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (l_tool));
|
1999-08-27 08:19:25 +08:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2002-08-26 19:35:56 +08:00
|
|
|
levels_write_to_file (GimpLevelsTool *l_tool,
|
|
|
|
FILE *file)
|
1999-08-27 08:19:25 +08:00
|
|
|
{
|
2002-08-26 19:35:56 +08:00
|
|
|
gint i;
|
2001-10-29 20:51:21 +08:00
|
|
|
gchar buf[G_ASCII_DTOSTR_BUF_SIZE];
|
1999-08-27 08:19:25 +08:00
|
|
|
|
2002-08-26 19:35:56 +08:00
|
|
|
fprintf (file, "# GIMP Levels File\n");
|
1999-08-28 06:02:18 +08:00
|
|
|
|
1999-08-27 08:19:25 +08:00
|
|
|
for (i = 0; i < 5; i++)
|
|
|
|
{
|
2002-08-26 19:35:56 +08:00
|
|
|
fprintf (file, "%d %d %d %d %s\n",
|
More color correction stuff cleanup:
2002-09-04 Michael Natterer <mitch@gimp.org>
More color correction stuff cleanup:
* app/base/Makefile.am
* app/base/base-types.h
* app/base/levels.[ch]: new files containing levels_lut_func(), a
new "Levels" parameter struct and the "auto levels" stuff.
* app/base/lut-funcs.[ch]: removed the levels stuff here, added
lots of g_return_if_fail().
* app/base/color-balance.[ch]
* app/base/hue-saturation.[ch]: added init() and reset() functions
so we don't need to duplicate this code in the tool and the pdb
wrappers.
* app/base/curves.[ch]: s/gint/GimpHistogramChannel/g, made
curves_channel_reset() initialize the curves array.
* app/tools/gimpcolorbalancetool.[ch]: use the new functions,
moved the "Range" frame to the top, added a per-range "Reset"
button, made the global "Reset" button reset all ranges and
the "Preserve Luminosity" toggle.
* app/tools/gimpcurvestool.[ch]: don't initialize the curves
array manually, as curves_channel_reset() does that,
s/gint/GimpHistogramChannel/g.
* app/tools/gimphuesaturationtool.c: use the new functions, added
a per-channel "Reset" button and made the global "Reset" button
reset all channels, cleaned up the GUI update function.
* app/tools/gimplevelstool.[ch]: changed to use the new Levels
parameter struct and it's utility functions. Removed stuff
which now lives in base/levels.c
* app/tools/gimpimagemaptool.c: align the "Preview" button
bottom-left, not bottom-right.
* tools/pdbgen/pdb/color.pdb: use the new stuff and removed
uglyness because using the "Levels" struct makes the code more
straightforward.
* app/pdb/color_cmds.c: regenerated.
2002-09-04 23:25:15 +08:00
|
|
|
l_tool->levels->low_input[i],
|
|
|
|
l_tool->levels->high_input[i],
|
|
|
|
l_tool->levels->low_output[i],
|
|
|
|
l_tool->levels->high_output[i],
|
2002-12-18 23:57:25 +08:00
|
|
|
g_ascii_formatd (buf, G_ASCII_DTOSTR_BUF_SIZE, "%f",
|
More color correction stuff cleanup:
2002-09-04 Michael Natterer <mitch@gimp.org>
More color correction stuff cleanup:
* app/base/Makefile.am
* app/base/base-types.h
* app/base/levels.[ch]: new files containing levels_lut_func(), a
new "Levels" parameter struct and the "auto levels" stuff.
* app/base/lut-funcs.[ch]: removed the levels stuff here, added
lots of g_return_if_fail().
* app/base/color-balance.[ch]
* app/base/hue-saturation.[ch]: added init() and reset() functions
so we don't need to duplicate this code in the tool and the pdb
wrappers.
* app/base/curves.[ch]: s/gint/GimpHistogramChannel/g, made
curves_channel_reset() initialize the curves array.
* app/tools/gimpcolorbalancetool.[ch]: use the new functions,
moved the "Range" frame to the top, added a per-range "Reset"
button, made the global "Reset" button reset all ranges and
the "Preserve Luminosity" toggle.
* app/tools/gimpcurvestool.[ch]: don't initialize the curves
array manually, as curves_channel_reset() does that,
s/gint/GimpHistogramChannel/g.
* app/tools/gimphuesaturationtool.c: use the new functions, added
a per-channel "Reset" button and made the global "Reset" button
reset all channels, cleaned up the GUI update function.
* app/tools/gimplevelstool.[ch]: changed to use the new Levels
parameter struct and it's utility functions. Removed stuff
which now lives in base/levels.c
* app/tools/gimpimagemaptool.c: align the "Preview" button
bottom-left, not bottom-right.
* tools/pdbgen/pdb/color.pdb: use the new stuff and removed
uglyness because using the "Levels" struct makes the code more
straightforward.
* app/pdb/color_cmds.c: regenerated.
2002-09-04 23:25:15 +08:00
|
|
|
l_tool->levels->gamma[i]));
|
1999-08-27 08:19:25 +08:00
|
|
|
}
|
|
|
|
}
|