gimp/app/base/color-balance.c

822 lines
23 KiB
C
Raw Normal View History

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
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1997-11-25 06:05:25 +08:00
*/
app/appenv.h New file. Includes <math.h>. Move G_PI, RINT(), ROUND() etc 1999-09-01 Tor Lillqvist <tml@iki.fi> * app/appenv.h * libgimp/gimpmath.h: New file. Includes <math.h>. Move G_PI, RINT(), ROUND() etc from app/appenv.h here, so plug-ins can use them, too. Remove some commented-out old stuff in appenv.h. * libgimp/gimp.h: Include gimpmath.h. * libgimp/gimp.c (gimp_main): Win32: Don't install signal handlers, we can't do anything useful in the handler ourselves anyway (it would be nice to print out a backtrace, but that seems pretty hard to do, even if not impossible). Let Windows inform the user about the crash. If the plug-in was compiled with MSVC, and the user also has it, she is offered a chance to start the debugger automatically anyway. * app/*several*.c: Include gimpmath.h for G_PI etc. Don't include <math.h>, as gimpmath.h includes it. * plug-ins/*/*many*.c: Include config.h. Don't include <math.h>. Remove all the duplicated definitions of G_PI and rint(). Use RINT() instead of rint(). * app/app_procs.[ch]: app_exit() takes a gboolean. * app/batch.c * app/commands.c * app/interface.c: Call app_exit() with FALSE or TRUE. * app/main.c (on_error): Call gimp_fatal_error. (main): Don't install any signal handler on Win32 here, either. * app/errors.c (gimp_fatal_error, gimp_terminate): Win32: Format the message and call MessageBox with it. g_on_error_query doesn't do anything useful on Win32, and printf'ing a message to stdout or stderr doesn't do anything, either, in a windowing application.
1999-09-02 04:30:56 +08:00
#include "config.h"
1997-11-25 06:05:25 +08:00
#include <stdlib.h>
#include <string.h>
app/appenv.h New file. Includes <math.h>. Move G_PI, RINT(), ROUND() etc 1999-09-01 Tor Lillqvist <tml@iki.fi> * app/appenv.h * libgimp/gimpmath.h: New file. Includes <math.h>. Move G_PI, RINT(), ROUND() etc from app/appenv.h here, so plug-ins can use them, too. Remove some commented-out old stuff in appenv.h. * libgimp/gimp.h: Include gimpmath.h. * libgimp/gimp.c (gimp_main): Win32: Don't install signal handlers, we can't do anything useful in the handler ourselves anyway (it would be nice to print out a backtrace, but that seems pretty hard to do, even if not impossible). Let Windows inform the user about the crash. If the plug-in was compiled with MSVC, and the user also has it, she is offered a chance to start the debugger automatically anyway. * app/*several*.c: Include gimpmath.h for G_PI etc. Don't include <math.h>, as gimpmath.h includes it. * plug-ins/*/*many*.c: Include config.h. Don't include <math.h>. Remove all the duplicated definitions of G_PI and rint(). Use RINT() instead of rint(). * app/app_procs.[ch]: app_exit() takes a gboolean. * app/batch.c * app/commands.c * app/interface.c: Call app_exit() with FALSE or TRUE. * app/main.c (on_error): Call gimp_fatal_error. (main): Don't install any signal handler on Win32 here, either. * app/errors.c (gimp_fatal_error, gimp_terminate): Win32: Format the message and call MessageBox with it. g_on_error_query doesn't do anything useful on Win32, and printf'ing a message to stdout or stderr doesn't do anything, either, in a windowing application.
1999-09-02 04:30:56 +08:00
1997-11-25 06:05:25 +08:00
#include "appenv.h"
#include "actionarea.h"
#include "color_balance.h"
#include "color_transfer.h"
#include "drawable.h"
#include "general.h"
#include "gimage_mask.h"
#include "gdisplay.h"
app/Makefile.am app/gimphelp.[ch] new files 1999-09-27 Michael Natterer <mitch@gimp.org> * app/Makefile.am * app/gimphelp.[ch] * app/gimpui.[ch]: new files * app/interface.[ch] * app/preferences_dialog.[ch] The GIMP Help System part 1: Press "F1" in any dialog to pop up the help page for this dialog. Moved the widget constructors from preferences_dialog.[ch] and the query boxes from interface.[ch] to gimpui.[ch]. The dialog constructors take a help_func and a help_data parameter and install the "F1" accelerator which emits the new "help" signal. The "help" signal callback calls help_func(help_data) which finally has to call gimp_help() which in turn invokes the help browser. Still have to find a proper way to (1) prevent "F1" being assigned to some menu item and (2) to catch "F1" while browsing the menu trees in order to pop up the help for the selected item. * app/menus.c: a <Toolbox>/File/Help... menu item. * app/commands.[ch]: a command callback for the "Help..." menu item. * app/gimprc.[ch]: new boolean gimprc variable "use_help". * app/info_dialog.[ch]: pass a help function and data to the info dialog constructor. * app/tools.[ch]: store the tools help page names in the tool info structure. Export a special tools_help_func() which shows the help page for the active tool. * app/[all files calling a dialog constructor]: pass the dialog's help page to the constructor. Most dialogs are now created by gimp_dialog_new() which also sets up the action_area and the WM delete event callback, so I removed the resp. code from these files. Fixed some minor bugs and did some other stuff but didn't change any logic except dialog creation. * plug-ins/helpbrowser/helpbrowser.c: don't try to call a running help browser and don't install any menu path (all done in app/gimphelp.[ch] now).
1999-09-28 01:58:10 +08:00
#include "gimpui.h"
1997-11-25 06:05:25 +08:00
#include "image_map.h"
#include "interface.h"
#include "libgimp/gimpintl.h"
app/appenv.h New file. Includes <math.h>. Move G_PI, RINT(), ROUND() etc 1999-09-01 Tor Lillqvist <tml@iki.fi> * app/appenv.h * libgimp/gimpmath.h: New file. Includes <math.h>. Move G_PI, RINT(), ROUND() etc from app/appenv.h here, so plug-ins can use them, too. Remove some commented-out old stuff in appenv.h. * libgimp/gimp.h: Include gimpmath.h. * libgimp/gimp.c (gimp_main): Win32: Don't install signal handlers, we can't do anything useful in the handler ourselves anyway (it would be nice to print out a backtrace, but that seems pretty hard to do, even if not impossible). Let Windows inform the user about the crash. If the plug-in was compiled with MSVC, and the user also has it, she is offered a chance to start the debugger automatically anyway. * app/*several*.c: Include gimpmath.h for G_PI etc. Don't include <math.h>, as gimpmath.h includes it. * plug-ins/*/*many*.c: Include config.h. Don't include <math.h>. Remove all the duplicated definitions of G_PI and rint(). Use RINT() instead of rint(). * app/app_procs.[ch]: app_exit() takes a gboolean. * app/batch.c * app/commands.c * app/interface.c: Call app_exit() with FALSE or TRUE. * app/main.c (on_error): Call gimp_fatal_error. (main): Don't install any signal handler on Win32 here, either. * app/errors.c (gimp_fatal_error, gimp_terminate): Win32: Format the message and call MessageBox with it. g_on_error_query doesn't do anything useful on Win32, and printf'ing a message to stdout or stderr doesn't do anything, either, in a windowing application.
1999-09-02 04:30:56 +08:00
#include "libgimp/gimpmath.h"
1997-11-25 06:05:25 +08:00
#define TEXT_WIDTH 55
#define CR_SLIDER 0x1
#define MG_SLIDER 0x2
#define YB_SLIDER 0x4
#define CR_TEXT 0x8
#define MG_TEXT 0x10
#define YB_TEXT 0x20
#define ALL 0xFF
/* the color balance structures */
1997-11-25 06:05:25 +08:00
typedef struct _ColorBalance ColorBalance;
1997-11-25 06:05:25 +08:00
struct _ColorBalance
{
int x, y; /* coords for last mouse click */
};
/* the color balance tool options */
app/airbrush.c app/bezier_select.c app/blend.c app/brightness_contrast.c 1999-04-12 Michael Natterer <mitschel@cs.tu-berlin.de> * app/airbrush.c * app/bezier_select.c * app/blend.c * app/brightness_contrast.c * app/bucket_fill.c * app/by_color_select.c * app/clone.c * app/color_balance.c * app/color_picker.c * app/convolve.c * app/crop.c * app/curves.c * app/ellipse_select.c * app/eraser.c * app/flip_tool.c * app/free_select.c * app/fuzzy_select.c * app/histogram_tool.c * app/hue_saturation.c * app/ink.c * app/iscissors.c * app/levels.c * app/magnify.c * app/move.c * app/paintbrush.c * app/pencil.c * app/posterize.c * app/rect_select.[ch] * app/text_tool.c * app/threshold.c * app/transform_tool.c * app/tools.[ch] * app/toolsF.h: again: all tools :( * app/Makefile.am * app/tool_options.[ch] * app/selection_options.h * app/tool_options_ui.h: new files. Ok, this time it's general enough for future extensions: - The tool options structures are organized like the gtk object system to allow derived tool options. - Renamed all create and reset functions to *_options_new() and *_options_reset() to reflect this. - Changed tools_register() again. Now it takes just a pointer to a ToolOptions structure. - Moved almost the entire tool options gui code to tool_options.c. - Visually separated the common selection options from the tool-specific ones. I'd like to do the same with opacity/paint mode in all paint tool options but I think this needs some more discussion. * app/histogram_tool.c: changed packing boxes, label alignments. * app/paintbrush.c: some more sensitive settings. The gradient feature can now be toggled with a button. Hopefully didn't break anything.
1999-04-13 01:55:06 +08:00
static ToolOptions *color_balance_options = NULL;
/* the color balance dialog */
static ColorBalanceDialog *color_balance_dialog = NULL;
1997-11-25 06:05:25 +08:00
/* color balance action functions */
namespace cleanups. 1999-06-21 Michael Natterer <mitschel@cs.tu-berlin.de> * app/context_manager.c: namespace cleanups. * app/commands.[ch] * app/menus.c: moved the "Toggle Selection" menu entry to "View", sprinkled some separators and made the layers/channels/paths popup menus consistent with Tigert's last ops buttons change. * app/fileops.c * app/plug_in.c: check for gdisplay_active() returning NULL in some more places. * app/[all tool related files]: - Turned the ToolAction and ToolState #define's into typedef'ed enums, so the compiler can do some more sanity checking. - Removed one more unused global variable "active_tool_layer". - Removed some #include's from tools.c. - Standardized the individual tools' structure names. - Moved showing/hiding the tool options to separate functions. - Stuff... * app/commands.c * app/disp_callbacks.c * app/gdisplay.c * app/tools.c: fixed the segfaults which happened when the image of one of the tools which have dialogs (levels/posterize/...) was deleted. My approach was to do stricter sanity checking and to set some gdisplay pointers correctly where appropriate, so I can't tell exactly where the bug was. The curves tool now(??) updates on every _second_ display change only, which is really obscure. Finding/changing the display to operate on should definitely be done by connecting to the user context's "display_changed" signal. * app/gimpset.c: emit the "remove" signal _after_ removing the pointer from the set. If this was not a bug but a feature, please let me know, we'll need two signals then.
1999-06-22 06:12:07 +08:00
static void color_balance_control (Tool *, ToolAction, gpointer);
namespace cleanups. 1999-06-21 Michael Natterer <mitschel@cs.tu-berlin.de> * app/context_manager.c: namespace cleanups. * app/commands.[ch] * app/menus.c: moved the "Toggle Selection" menu entry to "View", sprinkled some separators and made the layers/channels/paths popup menus consistent with Tigert's last ops buttons change. * app/fileops.c * app/plug_in.c: check for gdisplay_active() returning NULL in some more places. * app/[all tool related files]: - Turned the ToolAction and ToolState #define's into typedef'ed enums, so the compiler can do some more sanity checking. - Removed one more unused global variable "active_tool_layer". - Removed some #include's from tools.c. - Standardized the individual tools' structure names. - Moved showing/hiding the tool options to separate functions. - Stuff... * app/commands.c * app/disp_callbacks.c * app/gdisplay.c * app/tools.c: fixed the segfaults which happened when the image of one of the tools which have dialogs (levels/posterize/...) was deleted. My approach was to do stricter sanity checking and to set some gdisplay pointers correctly where appropriate, so I can't tell exactly where the bug was. The curves tool now(??) updates on every _second_ display change only, which is really obscure. Finding/changing the display to operate on should definitely be done by connecting to the user context's "display_changed" signal. * app/gimpset.c: emit the "remove" signal _after_ removing the pointer from the set. If this was not a bug but a feature, please let me know, we'll need two signals then.
1999-06-22 06:12:07 +08:00
static ColorBalanceDialog * color_balance_new_dialog (void);
static void color_balance_update (ColorBalanceDialog *, int);
static void color_balance_preview (ColorBalanceDialog *);
static void color_balance_ok_callback (GtkWidget *, gpointer);
static void color_balance_cancel_callback (GtkWidget *, gpointer);
static void color_balance_shadows_callback (GtkWidget *, gpointer);
static void color_balance_midtones_callback (GtkWidget *, gpointer);
static void color_balance_highlights_callback (GtkWidget *, gpointer);
static void color_balance_preserve_update (GtkWidget *, gpointer);
static void color_balance_preview_update (GtkWidget *, gpointer);
static void color_balance_cr_scale_update (GtkAdjustment *, gpointer);
static void color_balance_mg_scale_update (GtkAdjustment *, gpointer);
static void color_balance_yb_scale_update (GtkAdjustment *, gpointer);
static void color_balance_cr_text_update (GtkWidget *, gpointer);
static void color_balance_mg_text_update (GtkWidget *, gpointer);
static void color_balance_yb_text_update (GtkWidget *, gpointer);
1997-11-25 06:05:25 +08:00
app/airbrush.c app/bezier_select.c app/blend.c app/brightness_contrast.c 1999-04-12 Michael Natterer <mitschel@cs.tu-berlin.de> * app/airbrush.c * app/bezier_select.c * app/blend.c * app/brightness_contrast.c * app/bucket_fill.c * app/by_color_select.c * app/clone.c * app/color_balance.c * app/color_picker.c * app/convolve.c * app/crop.c * app/curves.c * app/ellipse_select.c * app/eraser.c * app/flip_tool.c * app/free_select.c * app/fuzzy_select.c * app/histogram_tool.c * app/hue_saturation.c * app/ink.c * app/iscissors.c * app/levels.c * app/magnify.c * app/move.c * app/paintbrush.c * app/pencil.c * app/posterize.c * app/rect_select.[ch] * app/text_tool.c * app/threshold.c * app/transform_tool.c * app/tools.[ch] * app/toolsF.h: again: all tools :( * app/Makefile.am * app/tool_options.[ch] * app/selection_options.h * app/tool_options_ui.h: new files. Ok, this time it's general enough for future extensions: - The tool options structures are organized like the gtk object system to allow derived tool options. - Renamed all create and reset functions to *_options_new() and *_options_reset() to reflect this. - Changed tools_register() again. Now it takes just a pointer to a ToolOptions structure. - Moved almost the entire tool options gui code to tool_options.c. - Visually separated the common selection options from the tool-specific ones. I'd like to do the same with opacity/paint mode in all paint tool options but I think this needs some more discussion. * app/histogram_tool.c: changed packing boxes, label alignments. * app/paintbrush.c: some more sensitive settings. The gradient feature can now be toggled with a button. Hopefully didn't break anything.
1999-04-13 01:55:06 +08:00
1997-11-25 06:05:25 +08:00
/* color balance machinery */
void
1997-11-25 06:05:25 +08:00
color_balance (PixelRegion *srcPR,
PixelRegion *destPR,
void *user_data)
{
ColorBalanceDialog *cbd;
unsigned char *src, *s;
unsigned char *dest, *d;
int alpha;
int r, g, b;
int r_n, g_n, b_n;
int w, h;
cbd = (ColorBalanceDialog *) user_data;
h = srcPR->h;
src = srcPR->data;
dest = destPR->data;
alpha = (srcPR->bytes == 4) ? TRUE : FALSE;
while (h--)
{
w = srcPR->w;
s = src;
d = dest;
while (w--)
{
r = s[RED_PIX];
g = s[GREEN_PIX];
b = s[BLUE_PIX];
r_n = cbd->r_lookup[r];
g_n = cbd->g_lookup[g];
b_n = cbd->b_lookup[b];
1997-11-25 06:05:25 +08:00
if (cbd->preserve_luminosity)
{
rgb_to_hls (&r_n, &g_n, &b_n);
g_n = rgb_to_l (r, g, b);
1997-11-25 06:05:25 +08:00
hls_to_rgb (&r_n, &g_n, &b_n);
}
d[RED_PIX] = r_n;
d[GREEN_PIX] = g_n;
d[BLUE_PIX] = b_n;
if (alpha)
d[ALPHA_PIX] = s[ALPHA_PIX];
s += srcPR->bytes;
d += destPR->bytes;
}
src += srcPR->rowstride;
dest += destPR->rowstride;
}
}
/* by_color select action functions */
static void
namespace cleanups. 1999-06-21 Michael Natterer <mitschel@cs.tu-berlin.de> * app/context_manager.c: namespace cleanups. * app/commands.[ch] * app/menus.c: moved the "Toggle Selection" menu entry to "View", sprinkled some separators and made the layers/channels/paths popup menus consistent with Tigert's last ops buttons change. * app/fileops.c * app/plug_in.c: check for gdisplay_active() returning NULL in some more places. * app/[all tool related files]: - Turned the ToolAction and ToolState #define's into typedef'ed enums, so the compiler can do some more sanity checking. - Removed one more unused global variable "active_tool_layer". - Removed some #include's from tools.c. - Standardized the individual tools' structure names. - Moved showing/hiding the tool options to separate functions. - Stuff... * app/commands.c * app/disp_callbacks.c * app/gdisplay.c * app/tools.c: fixed the segfaults which happened when the image of one of the tools which have dialogs (levels/posterize/...) was deleted. My approach was to do stricter sanity checking and to set some gdisplay pointers correctly where appropriate, so I can't tell exactly where the bug was. The curves tool now(??) updates on every _second_ display change only, which is really obscure. Finding/changing the display to operate on should definitely be done by connecting to the user context's "display_changed" signal. * app/gimpset.c: emit the "remove" signal _after_ removing the pointer from the set. If this was not a bug but a feature, please let me know, we'll need two signals then.
1999-06-22 06:12:07 +08:00
color_balance_control (Tool *tool,
ToolAction action,
gpointer gdisp_ptr)
1997-11-25 06:05:25 +08:00
{
ColorBalance * color_bal;
color_bal = (ColorBalance *) tool->private;
switch (action)
{
namespace cleanups. 1999-06-21 Michael Natterer <mitschel@cs.tu-berlin.de> * app/context_manager.c: namespace cleanups. * app/commands.[ch] * app/menus.c: moved the "Toggle Selection" menu entry to "View", sprinkled some separators and made the layers/channels/paths popup menus consistent with Tigert's last ops buttons change. * app/fileops.c * app/plug_in.c: check for gdisplay_active() returning NULL in some more places. * app/[all tool related files]: - Turned the ToolAction and ToolState #define's into typedef'ed enums, so the compiler can do some more sanity checking. - Removed one more unused global variable "active_tool_layer". - Removed some #include's from tools.c. - Standardized the individual tools' structure names. - Moved showing/hiding the tool options to separate functions. - Stuff... * app/commands.c * app/disp_callbacks.c * app/gdisplay.c * app/tools.c: fixed the segfaults which happened when the image of one of the tools which have dialogs (levels/posterize/...) was deleted. My approach was to do stricter sanity checking and to set some gdisplay pointers correctly where appropriate, so I can't tell exactly where the bug was. The curves tool now(??) updates on every _second_ display change only, which is really obscure. Finding/changing the display to operate on should definitely be done by connecting to the user context's "display_changed" signal. * app/gimpset.c: emit the "remove" signal _after_ removing the pointer from the set. If this was not a bug but a feature, please let me know, we'll need two signals then.
1999-06-22 06:12:07 +08:00
case PAUSE:
1997-11-25 06:05:25 +08:00
break;
namespace cleanups. 1999-06-21 Michael Natterer <mitschel@cs.tu-berlin.de> * app/context_manager.c: namespace cleanups. * app/commands.[ch] * app/menus.c: moved the "Toggle Selection" menu entry to "View", sprinkled some separators and made the layers/channels/paths popup menus consistent with Tigert's last ops buttons change. * app/fileops.c * app/plug_in.c: check for gdisplay_active() returning NULL in some more places. * app/[all tool related files]: - Turned the ToolAction and ToolState #define's into typedef'ed enums, so the compiler can do some more sanity checking. - Removed one more unused global variable "active_tool_layer". - Removed some #include's from tools.c. - Standardized the individual tools' structure names. - Moved showing/hiding the tool options to separate functions. - Stuff... * app/commands.c * app/disp_callbacks.c * app/gdisplay.c * app/tools.c: fixed the segfaults which happened when the image of one of the tools which have dialogs (levels/posterize/...) was deleted. My approach was to do stricter sanity checking and to set some gdisplay pointers correctly where appropriate, so I can't tell exactly where the bug was. The curves tool now(??) updates on every _second_ display change only, which is really obscure. Finding/changing the display to operate on should definitely be done by connecting to the user context's "display_changed" signal. * app/gimpset.c: emit the "remove" signal _after_ removing the pointer from the set. If this was not a bug but a feature, please let me know, we'll need two signals then.
1999-06-22 06:12:07 +08:00
case RESUME:
1997-11-25 06:05:25 +08:00
break;
namespace cleanups. 1999-06-21 Michael Natterer <mitschel@cs.tu-berlin.de> * app/context_manager.c: namespace cleanups. * app/commands.[ch] * app/menus.c: moved the "Toggle Selection" menu entry to "View", sprinkled some separators and made the layers/channels/paths popup menus consistent with Tigert's last ops buttons change. * app/fileops.c * app/plug_in.c: check for gdisplay_active() returning NULL in some more places. * app/[all tool related files]: - Turned the ToolAction and ToolState #define's into typedef'ed enums, so the compiler can do some more sanity checking. - Removed one more unused global variable "active_tool_layer". - Removed some #include's from tools.c. - Standardized the individual tools' structure names. - Moved showing/hiding the tool options to separate functions. - Stuff... * app/commands.c * app/disp_callbacks.c * app/gdisplay.c * app/tools.c: fixed the segfaults which happened when the image of one of the tools which have dialogs (levels/posterize/...) was deleted. My approach was to do stricter sanity checking and to set some gdisplay pointers correctly where appropriate, so I can't tell exactly where the bug was. The curves tool now(??) updates on every _second_ display change only, which is really obscure. Finding/changing the display to operate on should definitely be done by connecting to the user context's "display_changed" signal. * app/gimpset.c: emit the "remove" signal _after_ removing the pointer from the set. If this was not a bug but a feature, please let me know, we'll need two signals then.
1999-06-22 06:12:07 +08:00
case HALT:
1997-11-25 06:05:25 +08:00
if (color_balance_dialog)
color_balance_cancel_callback (NULL, (gpointer) color_balance_dialog);
1997-11-25 06:05:25 +08:00
break;
namespace cleanups. 1999-06-21 Michael Natterer <mitschel@cs.tu-berlin.de> * app/context_manager.c: namespace cleanups. * app/commands.[ch] * app/menus.c: moved the "Toggle Selection" menu entry to "View", sprinkled some separators and made the layers/channels/paths popup menus consistent with Tigert's last ops buttons change. * app/fileops.c * app/plug_in.c: check for gdisplay_active() returning NULL in some more places. * app/[all tool related files]: - Turned the ToolAction and ToolState #define's into typedef'ed enums, so the compiler can do some more sanity checking. - Removed one more unused global variable "active_tool_layer". - Removed some #include's from tools.c. - Standardized the individual tools' structure names. - Moved showing/hiding the tool options to separate functions. - Stuff... * app/commands.c * app/disp_callbacks.c * app/gdisplay.c * app/tools.c: fixed the segfaults which happened when the image of one of the tools which have dialogs (levels/posterize/...) was deleted. My approach was to do stricter sanity checking and to set some gdisplay pointers correctly where appropriate, so I can't tell exactly where the bug was. The curves tool now(??) updates on every _second_ display change only, which is really obscure. Finding/changing the display to operate on should definitely be done by connecting to the user context's "display_changed" signal. * app/gimpset.c: emit the "remove" signal _after_ removing the pointer from the set. If this was not a bug but a feature, please let me know, we'll need two signals then.
1999-06-22 06:12:07 +08:00
default:
break;
1997-11-25 06:05:25 +08:00
}
}
Tool *
tools_new_color_balance ()
{
Tool * tool;
ColorBalance * private;
/* The tool options */
if (!color_balance_options)
{
app/airbrush.c app/bezier_select.c app/blend.c app/brightness_contrast.c 1999-04-12 Michael Natterer <mitschel@cs.tu-berlin.de> * app/airbrush.c * app/bezier_select.c * app/blend.c * app/brightness_contrast.c * app/bucket_fill.c * app/by_color_select.c * app/clone.c * app/color_balance.c * app/color_picker.c * app/convolve.c * app/crop.c * app/curves.c * app/ellipse_select.c * app/eraser.c * app/flip_tool.c * app/free_select.c * app/fuzzy_select.c * app/histogram_tool.c * app/hue_saturation.c * app/ink.c * app/iscissors.c * app/levels.c * app/magnify.c * app/move.c * app/paintbrush.c * app/pencil.c * app/posterize.c * app/rect_select.[ch] * app/text_tool.c * app/threshold.c * app/transform_tool.c * app/tools.[ch] * app/toolsF.h: again: all tools :( * app/Makefile.am * app/tool_options.[ch] * app/selection_options.h * app/tool_options_ui.h: new files. Ok, this time it's general enough for future extensions: - The tool options structures are organized like the gtk object system to allow derived tool options. - Renamed all create and reset functions to *_options_new() and *_options_reset() to reflect this. - Changed tools_register() again. Now it takes just a pointer to a ToolOptions structure. - Moved almost the entire tool options gui code to tool_options.c. - Visually separated the common selection options from the tool-specific ones. I'd like to do the same with opacity/paint mode in all paint tool options but I think this needs some more discussion. * app/histogram_tool.c: changed packing boxes, label alignments. * app/paintbrush.c: some more sensitive settings. The gradient feature can now be toggled with a button. Hopefully didn't break anything.
1999-04-13 01:55:06 +08:00
color_balance_options = tool_options_new (_("Color Balance Options"));
tools_register (COLOR_BALANCE, color_balance_options);
}
1997-11-25 06:05:25 +08:00
tool = tools_new_tool (COLOR_BALANCE);
private = g_new (ColorBalance, 1);
1997-11-25 06:05:25 +08:00
tool->scroll_lock = TRUE; /* Disallow scrolling */
tool->preserve = FALSE; /* Don't preserve on drawable change */
tool->private = (void *) private;
1997-11-25 06:05:25 +08:00
tool->control_func = color_balance_control;
return tool;
}
void
tools_free_color_balance (Tool *tool)
{
ColorBalance * color_bal;
color_bal = (ColorBalance *) tool->private;
/* Close the color select dialog */
if (color_balance_dialog)
color_balance_cancel_callback (NULL, (gpointer) color_balance_dialog);
1997-11-25 06:05:25 +08:00
g_free (color_bal);
}
void
color_balance_initialize (GDisplay *gdisp)
1997-11-25 06:05:25 +08:00
{
int i;
if (! drawable_color (gimage_active_drawable (gdisp->gimage)))
{
g_message (_("Color balance operates only on RGB color drawables."));
1997-11-25 06:05:25 +08:00
return;
}
/* The color balance dialog */
if (!color_balance_dialog)
color_balance_dialog = color_balance_new_dialog ();
else
if (!GTK_WIDGET_VISIBLE (color_balance_dialog->shell))
gtk_widget_show (color_balance_dialog->shell);
/* Initialize dialog fields */
color_balance_dialog->image_map = NULL;
for (i = 0; i < 3; i++)
{
color_balance_dialog->cyan_red[i] = 0.0;
color_balance_dialog->magenta_green[i] = 0.0;
color_balance_dialog->yellow_blue[i] = 0.0;
}
color_balance_dialog->drawable = gimage_active_drawable (gdisp->gimage);
color_balance_dialog->image_map =
image_map_create (gdisp, color_balance_dialog->drawable);
1997-11-25 06:05:25 +08:00
color_balance_update (color_balance_dialog, ALL);
}
/**************************/
/* Color Balance dialog */
/**************************/
1997-11-25 06:05:25 +08:00
static ColorBalanceDialog *
1997-11-25 06:05:25 +08:00
color_balance_new_dialog ()
{
ColorBalanceDialog *cbd;
GtkWidget *vbox;
GtkWidget *hbox;
GtkWidget *table;
GtkWidget *start_label;
GtkWidget *end_label;
GtkWidget *label;
GtkWidget *slider;
GtkWidget *toggle;
GtkWidget *radio_button;
GtkObject *data;
GSList *group = NULL;
app/Makefile.am app/gimphelp.[ch] new files 1999-09-27 Michael Natterer <mitch@gimp.org> * app/Makefile.am * app/gimphelp.[ch] * app/gimpui.[ch]: new files * app/interface.[ch] * app/preferences_dialog.[ch] The GIMP Help System part 1: Press "F1" in any dialog to pop up the help page for this dialog. Moved the widget constructors from preferences_dialog.[ch] and the query boxes from interface.[ch] to gimpui.[ch]. The dialog constructors take a help_func and a help_data parameter and install the "F1" accelerator which emits the new "help" signal. The "help" signal callback calls help_func(help_data) which finally has to call gimp_help() which in turn invokes the help browser. Still have to find a proper way to (1) prevent "F1" being assigned to some menu item and (2) to catch "F1" while browsing the menu trees in order to pop up the help for the selected item. * app/menus.c: a <Toolbox>/File/Help... menu item. * app/commands.[ch]: a command callback for the "Help..." menu item. * app/gimprc.[ch]: new boolean gimprc variable "use_help". * app/info_dialog.[ch]: pass a help function and data to the info dialog constructor. * app/tools.[ch]: store the tools help page names in the tool info structure. Export a special tools_help_func() which shows the help page for the active tool. * app/[all files calling a dialog constructor]: pass the dialog's help page to the constructor. Most dialogs are now created by gimp_dialog_new() which also sets up the action_area and the WM delete event callback, so I removed the resp. code from these files. Fixed some minor bugs and did some other stuff but didn't change any logic except dialog creation. * plug-ins/helpbrowser/helpbrowser.c: don't try to call a running help browser and don't install any menu path (all done in app/gimphelp.[ch] now).
1999-09-28 01:58:10 +08:00
gint i;
app/Makefile.am app/gimphelp.[ch] new files 1999-09-27 Michael Natterer <mitch@gimp.org> * app/Makefile.am * app/gimphelp.[ch] * app/gimpui.[ch]: new files * app/interface.[ch] * app/preferences_dialog.[ch] The GIMP Help System part 1: Press "F1" in any dialog to pop up the help page for this dialog. Moved the widget constructors from preferences_dialog.[ch] and the query boxes from interface.[ch] to gimpui.[ch]. The dialog constructors take a help_func and a help_data parameter and install the "F1" accelerator which emits the new "help" signal. The "help" signal callback calls help_func(help_data) which finally has to call gimp_help() which in turn invokes the help browser. Still have to find a proper way to (1) prevent "F1" being assigned to some menu item and (2) to catch "F1" while browsing the menu trees in order to pop up the help for the selected item. * app/menus.c: a <Toolbox>/File/Help... menu item. * app/commands.[ch]: a command callback for the "Help..." menu item. * app/gimprc.[ch]: new boolean gimprc variable "use_help". * app/info_dialog.[ch]: pass a help function and data to the info dialog constructor. * app/tools.[ch]: store the tools help page names in the tool info structure. Export a special tools_help_func() which shows the help page for the active tool. * app/[all files calling a dialog constructor]: pass the dialog's help page to the constructor. Most dialogs are now created by gimp_dialog_new() which also sets up the action_area and the WM delete event callback, so I removed the resp. code from these files. Fixed some minor bugs and did some other stuff but didn't change any logic except dialog creation. * plug-ins/helpbrowser/helpbrowser.c: don't try to call a running help browser and don't install any menu path (all done in app/gimphelp.[ch] now).
1999-09-28 01:58:10 +08:00
gchar *appl_mode_names[] =
1997-11-25 06:05:25 +08:00
{
N_("Shadows"),
N_("Midtones"),
N_("Highlights")
1997-11-25 06:05:25 +08:00
};
ActionCallback appl_mode_callbacks[] =
1997-11-25 06:05:25 +08:00
{
color_balance_shadows_callback,
color_balance_midtones_callback,
color_balance_highlights_callback
};
cbd = g_malloc (sizeof (ColorBalanceDialog));
cbd->preserve_luminosity = TRUE;
cbd->preview = TRUE;
cbd->application_mode = SHADOWS;
/* The shell and main vbox */
app/Makefile.am app/gimphelp.[ch] new files 1999-09-27 Michael Natterer <mitch@gimp.org> * app/Makefile.am * app/gimphelp.[ch] * app/gimpui.[ch]: new files * app/interface.[ch] * app/preferences_dialog.[ch] The GIMP Help System part 1: Press "F1" in any dialog to pop up the help page for this dialog. Moved the widget constructors from preferences_dialog.[ch] and the query boxes from interface.[ch] to gimpui.[ch]. The dialog constructors take a help_func and a help_data parameter and install the "F1" accelerator which emits the new "help" signal. The "help" signal callback calls help_func(help_data) which finally has to call gimp_help() which in turn invokes the help browser. Still have to find a proper way to (1) prevent "F1" being assigned to some menu item and (2) to catch "F1" while browsing the menu trees in order to pop up the help for the selected item. * app/menus.c: a <Toolbox>/File/Help... menu item. * app/commands.[ch]: a command callback for the "Help..." menu item. * app/gimprc.[ch]: new boolean gimprc variable "use_help". * app/info_dialog.[ch]: pass a help function and data to the info dialog constructor. * app/tools.[ch]: store the tools help page names in the tool info structure. Export a special tools_help_func() which shows the help page for the active tool. * app/[all files calling a dialog constructor]: pass the dialog's help page to the constructor. Most dialogs are now created by gimp_dialog_new() which also sets up the action_area and the WM delete event callback, so I removed the resp. code from these files. Fixed some minor bugs and did some other stuff but didn't change any logic except dialog creation. * plug-ins/helpbrowser/helpbrowser.c: don't try to call a running help browser and don't install any menu path (all done in app/gimphelp.[ch] now).
1999-09-28 01:58:10 +08:00
cbd->shell = gimp_dialog_new (_("Color Balance"), "color_balance",
tools_help_func, NULL,
GTK_WIN_POS_NONE,
FALSE, TRUE, FALSE,
_("OK"), color_balance_ok_callback,
cbd, NULL, TRUE, FALSE,
_("Cancel"), color_balance_cancel_callback,
cbd, NULL, FALSE, TRUE,
NULL);
1997-11-25 06:05:25 +08:00
vbox = gtk_vbox_new (FALSE, 2);
gtk_container_set_border_width (GTK_CONTAINER (vbox), 2);
app/Makefile.am app/gimphelp.[ch] new files 1999-09-27 Michael Natterer <mitch@gimp.org> * app/Makefile.am * app/gimphelp.[ch] * app/gimpui.[ch]: new files * app/interface.[ch] * app/preferences_dialog.[ch] The GIMP Help System part 1: Press "F1" in any dialog to pop up the help page for this dialog. Moved the widget constructors from preferences_dialog.[ch] and the query boxes from interface.[ch] to gimpui.[ch]. The dialog constructors take a help_func and a help_data parameter and install the "F1" accelerator which emits the new "help" signal. The "help" signal callback calls help_func(help_data) which finally has to call gimp_help() which in turn invokes the help browser. Still have to find a proper way to (1) prevent "F1" being assigned to some menu item and (2) to catch "F1" while browsing the menu trees in order to pop up the help for the selected item. * app/menus.c: a <Toolbox>/File/Help... menu item. * app/commands.[ch]: a command callback for the "Help..." menu item. * app/gimprc.[ch]: new boolean gimprc variable "use_help". * app/info_dialog.[ch]: pass a help function and data to the info dialog constructor. * app/tools.[ch]: store the tools help page names in the tool info structure. Export a special tools_help_func() which shows the help page for the active tool. * app/[all files calling a dialog constructor]: pass the dialog's help page to the constructor. Most dialogs are now created by gimp_dialog_new() which also sets up the action_area and the WM delete event callback, so I removed the resp. code from these files. Fixed some minor bugs and did some other stuff but didn't change any logic except dialog creation. * plug-ins/helpbrowser/helpbrowser.c: don't try to call a running help browser and don't install any menu path (all done in app/gimphelp.[ch] now).
1999-09-28 01:58:10 +08:00
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (cbd->shell)->vbox), vbox);
1997-11-25 06:05:25 +08:00
/* Horizontal box for application mode */
hbox = gtk_hbox_new (TRUE, 2);
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
label = gtk_label_new (_("Color Levels: "));
1997-11-25 06:05:25 +08:00
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, FALSE, 0);
gtk_widget_show (label);
/* cyan-red text */
cbd->cyan_red_text = gtk_entry_new ();
gtk_widget_set_usize (cbd->cyan_red_text, TEXT_WIDTH, 25);
gtk_box_pack_start (GTK_BOX (hbox), cbd->cyan_red_text, TRUE, FALSE, 0);
gtk_signal_connect (GTK_OBJECT (cbd->cyan_red_text), "changed",
(GtkSignalFunc) color_balance_cr_text_update,
cbd);
gtk_widget_show (cbd->cyan_red_text);
/* magenta-green text */
cbd->magenta_green_text = gtk_entry_new ();
gtk_widget_set_usize (cbd->magenta_green_text, TEXT_WIDTH, 25);
gtk_box_pack_start (GTK_BOX (hbox), cbd->magenta_green_text, TRUE, FALSE, 0);
gtk_signal_connect (GTK_OBJECT (cbd->magenta_green_text), "changed",
(GtkSignalFunc) color_balance_mg_text_update,
cbd);
gtk_widget_show (cbd->magenta_green_text);
/* yellow-blue text */
cbd->yellow_blue_text = gtk_entry_new ();
gtk_widget_set_usize (cbd->yellow_blue_text, TEXT_WIDTH, 25);
gtk_box_pack_start (GTK_BOX (hbox), cbd->yellow_blue_text, TRUE, FALSE, 0);
gtk_signal_connect (GTK_OBJECT (cbd->yellow_blue_text), "changed",
(GtkSignalFunc) color_balance_yb_text_update,
cbd);
gtk_widget_show (cbd->yellow_blue_text);
gtk_widget_show (hbox);
/* The table containing sliders */
table = gtk_table_new (3, 3, FALSE);
gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, FALSE, 0);
/* Create the cyan-red scale widget */
start_label = gtk_label_new (_("Cyan"));
1997-11-25 06:05:25 +08:00
gtk_misc_set_alignment (GTK_MISC (start_label), 1.0, 1.0);
gtk_table_attach (GTK_TABLE (table), start_label, 0, 1, 0, 1,
GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 2, 2);
data = gtk_adjustment_new (0, -100.0, 100.0, 1.0, 1.0, 0.0);
cbd->cyan_red_data = GTK_ADJUSTMENT (data);
slider = gtk_hscale_new (GTK_ADJUSTMENT (data));
gtk_scale_set_digits (GTK_SCALE (slider), 0);
gtk_table_attach (GTK_TABLE (table), slider, 1, 2, 0, 1,
GTK_EXPAND | GTK_SHRINK | GTK_FILL,
GTK_EXPAND | GTK_SHRINK | GTK_FILL,
2, 2);
gtk_scale_set_value_pos (GTK_SCALE (slider), GTK_POS_TOP);
gtk_range_set_update_policy (GTK_RANGE (slider), GTK_UPDATE_DELAYED);
gtk_signal_connect (GTK_OBJECT (data), "value_changed",
(GtkSignalFunc) color_balance_cr_scale_update,
cbd);
end_label = gtk_label_new (_("Red"));
1997-11-25 06:05:25 +08:00
gtk_misc_set_alignment (GTK_MISC (end_label), 0.0, 1.0);
gtk_table_attach (GTK_TABLE (table), end_label, 2, 3, 0, 1,
GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 2, 2);
gtk_widget_show (start_label);
gtk_widget_show (end_label);
gtk_widget_show (slider);
/* Create the magenta-green scale widget */
start_label = gtk_label_new (_("Magenta"));
1997-11-25 06:05:25 +08:00
gtk_misc_set_alignment (GTK_MISC (start_label), 1.0, 1.0);
gtk_table_attach (GTK_TABLE (table), start_label, 0, 1, 1, 2,
GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 2, 2);
data = gtk_adjustment_new (0, -100.0, 100.0, 1.0, 1.0, 0.0);
cbd->magenta_green_data = GTK_ADJUSTMENT (data);
slider = gtk_hscale_new (GTK_ADJUSTMENT (data));
gtk_scale_set_digits (GTK_SCALE (slider), 0);
gtk_table_attach (GTK_TABLE (table), slider, 1, 2, 1, 2,
GTK_EXPAND | GTK_SHRINK | GTK_FILL,
GTK_EXPAND | GTK_SHRINK | GTK_FILL,
2, 2);
gtk_scale_set_value_pos (GTK_SCALE (slider), GTK_POS_TOP);
gtk_range_set_update_policy (GTK_RANGE (slider), GTK_UPDATE_DELAYED);
gtk_signal_connect (GTK_OBJECT (data), "value_changed",
(GtkSignalFunc) color_balance_mg_scale_update,
cbd);
end_label = gtk_label_new (_("Green"));
1997-11-25 06:05:25 +08:00
gtk_misc_set_alignment (GTK_MISC (end_label), 0.0, 1.0);
gtk_table_attach (GTK_TABLE (table), end_label, 2, 3, 1, 2,
GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 2, 2);
gtk_widget_show (start_label);
gtk_widget_show (end_label);
gtk_widget_show (slider);
/* Create the yellow-blue scale widget */
start_label = gtk_label_new (_("Yellow"));
1997-11-25 06:05:25 +08:00
gtk_misc_set_alignment (GTK_MISC (start_label), 1.0, 1.0);
gtk_table_attach (GTK_TABLE (table), start_label, 0, 1, 2, 3,
GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 2, 2);
data = gtk_adjustment_new (0, -100.0, 100.0, 1.0, 1.0, 0.0);
cbd->yellow_blue_data = GTK_ADJUSTMENT (data);
slider = gtk_hscale_new (GTK_ADJUSTMENT (data));
gtk_scale_set_digits (GTK_SCALE (slider), 0);
gtk_table_attach (GTK_TABLE (table), slider, 1, 2, 2, 3,
GTK_EXPAND | GTK_SHRINK | GTK_FILL,
GTK_EXPAND | GTK_SHRINK | GTK_FILL,
2, 2);
gtk_scale_set_value_pos (GTK_SCALE (slider), GTK_POS_TOP);
gtk_range_set_update_policy (GTK_RANGE (slider), GTK_UPDATE_DELAYED);
gtk_signal_connect (GTK_OBJECT (data), "value_changed",
(GtkSignalFunc) color_balance_yb_scale_update,
cbd);
end_label = gtk_label_new (_("Blue"));
1997-11-25 06:05:25 +08:00
gtk_misc_set_alignment (GTK_MISC (end_label), 0.0, 1.0);
gtk_table_attach (GTK_TABLE (table), end_label, 2, 3, 2, 3,
GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 2, 2);
gtk_widget_show (start_label);
gtk_widget_show (end_label);
gtk_widget_show (slider);
/* Horizontal box for preview and preserve luminosity toggle buttons */
hbox = gtk_hbox_new (TRUE, 2);
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
/* The preview toggle */
toggle = gtk_check_button_new_with_label (_("Preview"));
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle), cbd->preview);
1997-11-25 06:05:25 +08:00
gtk_box_pack_start (GTK_BOX (hbox), toggle, TRUE, FALSE, 0);
gtk_signal_connect (GTK_OBJECT (toggle), "toggled",
(GtkSignalFunc) color_balance_preview_update,
cbd);
gtk_widget_show (toggle);
/* The preserve luminosity toggle */
toggle = gtk_check_button_new_with_label (_("Preserve Luminosity"));
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle), cbd->preserve_luminosity);
1997-11-25 06:05:25 +08:00
gtk_box_pack_start (GTK_BOX (hbox), toggle, TRUE, FALSE, 0);
gtk_signal_connect (GTK_OBJECT (toggle), "toggled",
(GtkSignalFunc) color_balance_preserve_update,
cbd);
gtk_widget_show (toggle);
gtk_widget_show (hbox);
/* Horizontal box for application mode */
hbox = gtk_hbox_new (TRUE, 2);
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
/* the radio buttons for application mode */
for (i = 0; i < 3; i++)
{
radio_button = gtk_radio_button_new_with_label (group, appl_mode_names[i]);
group = gtk_radio_button_group (GTK_RADIO_BUTTON (radio_button));
gtk_box_pack_start (GTK_BOX (hbox), radio_button, FALSE, FALSE, 0);
gtk_signal_connect (GTK_OBJECT (radio_button), "toggled",
(GtkSignalFunc) appl_mode_callbacks[i],
cbd);
gtk_widget_show (radio_button);
}
gtk_widget_show (hbox);
gtk_widget_show (table);
gtk_widget_show (vbox);
gtk_widget_show (cbd->shell);
return cbd;
}
static void
color_balance_update (ColorBalanceDialog *cbd,
int update)
{
char text[12];
if (update & CR_SLIDER)
{
cbd->cyan_red_data->value = cbd->cyan_red[cbd->application_mode];
gtk_signal_emit_by_name (GTK_OBJECT (cbd->cyan_red_data), "value_changed");
}
if (update & MG_SLIDER)
{
cbd->magenta_green_data->value = cbd->magenta_green[cbd->application_mode];
gtk_signal_emit_by_name (GTK_OBJECT (cbd->magenta_green_data), "value_changed");
}
if (update & YB_SLIDER)
{
cbd->yellow_blue_data->value = cbd->yellow_blue[cbd->application_mode];
gtk_signal_emit_by_name (GTK_OBJECT (cbd->yellow_blue_data), "value_changed");
}
if (update & CR_TEXT)
{
sprintf (text, "%0.0f", cbd->cyan_red[cbd->application_mode]);
gtk_entry_set_text (GTK_ENTRY (cbd->cyan_red_text), text);
}
if (update & MG_TEXT)
{
sprintf (text, "%0.0f", cbd->magenta_green[cbd->application_mode]);
gtk_entry_set_text (GTK_ENTRY (cbd->magenta_green_text), text);
}
if (update & YB_TEXT)
{
sprintf (text, "%0.0f", cbd->yellow_blue[cbd->application_mode]);
gtk_entry_set_text (GTK_ENTRY (cbd->yellow_blue_text), text);
}
}
void
color_balance_create_lookup_tables (ColorBalanceDialog *cbd)
{
double *cyan_red_transfer[3];
double *magenta_green_transfer[3];
double *yellow_blue_transfer[3];
int i;
gint32 r_n, g_n, b_n;
/* Set the transfer arrays (for speed) */
cyan_red_transfer[SHADOWS] = (cbd->cyan_red[SHADOWS] > 0) ? shadows_add : shadows_sub;
cyan_red_transfer[MIDTONES] = (cbd->cyan_red[MIDTONES] > 0) ? midtones_add : midtones_sub;
cyan_red_transfer[HIGHLIGHTS] = (cbd->cyan_red[HIGHLIGHTS] > 0) ? highlights_add : highlights_sub;
magenta_green_transfer[SHADOWS] = (cbd->magenta_green[SHADOWS] > 0) ? shadows_add : shadows_sub;
magenta_green_transfer[MIDTONES] = (cbd->magenta_green[MIDTONES] > 0) ? midtones_add : midtones_sub;
magenta_green_transfer[HIGHLIGHTS] = (cbd->magenta_green[HIGHLIGHTS] > 0) ? highlights_add : highlights_sub;
yellow_blue_transfer[SHADOWS] = (cbd->yellow_blue[SHADOWS] > 0) ? shadows_add : shadows_sub;
yellow_blue_transfer[MIDTONES] = (cbd->yellow_blue[MIDTONES] > 0) ? midtones_add : midtones_sub;
yellow_blue_transfer[HIGHLIGHTS] = (cbd->yellow_blue[HIGHLIGHTS] > 0) ? highlights_add : highlights_sub;
for (i = 0; i < 256; i++)
{
r_n = i;
g_n = i;
b_n = i;
r_n += cbd->cyan_red[SHADOWS] * cyan_red_transfer[SHADOWS][r_n];
r_n = CLAMP0255 (r_n);
r_n += cbd->cyan_red[MIDTONES] * cyan_red_transfer[MIDTONES][r_n];
r_n = CLAMP0255 (r_n);
r_n += cbd->cyan_red[HIGHLIGHTS] * cyan_red_transfer[HIGHLIGHTS][r_n];
r_n = CLAMP0255 (r_n);
g_n += cbd->magenta_green[SHADOWS] * magenta_green_transfer[SHADOWS][g_n];
g_n = CLAMP0255 (g_n);
g_n += cbd->magenta_green[MIDTONES] * magenta_green_transfer[MIDTONES][g_n];
g_n = CLAMP0255 (g_n);
g_n += cbd->magenta_green[HIGHLIGHTS] * magenta_green_transfer[HIGHLIGHTS][g_n];
g_n = CLAMP0255 (g_n);
b_n += cbd->yellow_blue[SHADOWS] * yellow_blue_transfer[SHADOWS][b_n];
b_n = CLAMP0255 (b_n);
b_n += cbd->yellow_blue[MIDTONES] * yellow_blue_transfer[MIDTONES][b_n];
b_n = CLAMP0255 (b_n);
b_n += cbd->yellow_blue[HIGHLIGHTS] * yellow_blue_transfer[HIGHLIGHTS][b_n];
b_n = CLAMP0255 (b_n);
cbd->r_lookup[i] = r_n;
cbd->g_lookup[i] = g_n;
cbd->b_lookup[i] = b_n;
}
}
1997-11-25 06:05:25 +08:00
static void
color_balance_preview (ColorBalanceDialog *cbd)
{
if (!cbd->image_map)
configure.in removed tips files, AC_SUBST GIMP_PLUGINS and GIMP_MODULES so * configure.in * Makefile.am: removed tips files, AC_SUBST GIMP_PLUGINS and GIMP_MODULES so you can easily skip those parts of the build * acinclude.m4 * config.sub * config.guess * ltconfig * ltmain.sh: libtool 1.3.2 * app/fileops.c: shuffle #includes to avoid warning about MIN and MAX [ The following is a big i18n patch from David Monniaux <david.monniaux@ens.fr> ] * tips/gimp_conseils.fr.txt * tips/gimp_tips.txt * tips/Makefile.am * configure.in: moved tips to separate dir * po-plugins: new dir for plug-in translation files * configure.in: add po-plugins dir and POTFILES processing * app/boundary.c * app/brightness_contrast.c * app/by_color_select.c * app/color_balance.c * app/convert.c * app/curves.c * app/free_select.c * app/gdisplay.c * app/gimpimage.c * app/gimpunit.c * app/gradient.c * app/gradient_select.c * app/install.c * app/session.c: various i18n tweaks * app/tips_dialog.c: localize tips filename * libgimp/gimpunit.c * libgimp/gimpunitmenu.c: #include "config.h" * plug-ins/CEL * plug-ins/CML_explorer * plug-ins/Lighting * plug-ins/apply_lens * plug-ins/autostretch_hsv * plug-ins/blur * plug-ins/bmp * plug-ins/borderaverage * plug-ins/bumpmap * plug-ins/bz2 * plug-ins/checkerboard * plug-ins/colorify * plug-ins/compose * plug-ins/convmatrix * plug-ins/cubism * plug-ins/depthmerge * plug-ins/destripe * plug-ins/gif * plug-ins/gifload * plug-ins/jpeg * plug-ins/mail * plug-ins/oilify * plug-ins/png * plug-ins/print * plug-ins/ps * plug-ins/xbm * plug-ins/xpm * plug-ins/xwd: plug-in i18n stuff -Yosh
1999-05-30 00:35:47 +08:00
g_message ("color_balance_preview(): No image map");
active_tool->preserve = TRUE;
color_balance_create_lookup_tables(cbd);
1997-11-25 06:05:25 +08:00
image_map_apply (cbd->image_map, color_balance, (void *) cbd);
active_tool->preserve = FALSE;
1997-11-25 06:05:25 +08:00
}
static void
color_balance_ok_callback (GtkWidget *widget,
gpointer client_data)
{
ColorBalanceDialog *cbd;
cbd = (ColorBalanceDialog *) client_data;
if (GTK_WIDGET_VISIBLE (cbd->shell))
gtk_widget_hide (cbd->shell);
active_tool->preserve = TRUE;
1997-11-25 06:05:25 +08:00
if (!cbd->preview)
image_map_apply (cbd->image_map, color_balance, (void *) cbd);
if (cbd->image_map)
image_map_commit (cbd->image_map);
active_tool->preserve = FALSE;
1997-11-25 06:05:25 +08:00
cbd->image_map = NULL;
active_tool->gdisp_ptr = NULL;
active_tool->drawable = NULL;
1997-11-25 06:05:25 +08:00
}
static void
color_balance_cancel_callback (GtkWidget *widget,
gpointer client_data)
{
ColorBalanceDialog *cbd;
cbd = (ColorBalanceDialog *) client_data;
if (GTK_WIDGET_VISIBLE (cbd->shell))
gtk_widget_hide (cbd->shell);
if (cbd->image_map)
{
active_tool->preserve = TRUE;
1997-11-25 06:05:25 +08:00
image_map_abort (cbd->image_map);
active_tool->preserve = FALSE;
1997-11-25 06:05:25 +08:00
gdisplays_flush ();
cbd->image_map = NULL;
1997-11-25 06:05:25 +08:00
}
active_tool->gdisp_ptr = NULL;
active_tool->drawable = NULL;
1997-11-25 06:05:25 +08:00
}
static void
color_balance_shadows_callback (GtkWidget *widget,
gpointer client_data)
{
ColorBalanceDialog *cbd;
cbd = (ColorBalanceDialog *) client_data;
cbd->application_mode = SHADOWS;
color_balance_update (cbd, ALL);
}
static void
color_balance_midtones_callback (GtkWidget *widget,
gpointer client_data)
{
ColorBalanceDialog *cbd;
cbd = (ColorBalanceDialog *) client_data;
cbd->application_mode = MIDTONES;
color_balance_update (cbd, ALL);
}
static void
color_balance_highlights_callback (GtkWidget *widget,
gpointer client_data)
{
ColorBalanceDialog *cbd;
cbd = (ColorBalanceDialog *) client_data;
cbd->application_mode = HIGHLIGHTS;
color_balance_update (cbd, ALL);
}
static void
color_balance_preserve_update (GtkWidget *w,
gpointer data)
{
ColorBalanceDialog *cbd;
cbd = (ColorBalanceDialog *) data;
if (GTK_TOGGLE_BUTTON (w)->active)
{
cbd->preserve_luminosity = TRUE;
if (cbd->preview)
color_balance_preview (cbd);
}
else
{
cbd->preserve_luminosity = FALSE;
if (cbd->preview)
color_balance_preview (cbd);
}
}
static void
color_balance_preview_update (GtkWidget *w,
gpointer data)
{
ColorBalanceDialog *cbd;
cbd = (ColorBalanceDialog *) data;
if (GTK_TOGGLE_BUTTON (w)->active)
{
cbd->preview = TRUE;
color_balance_preview (cbd);
}
else
cbd->preview = FALSE;
}
static void
color_balance_cr_scale_update (GtkAdjustment *adjustment,
gpointer data)
{
ColorBalanceDialog *cbd;
cbd = (ColorBalanceDialog *) data;
if (cbd->cyan_red[cbd->application_mode] != adjustment->value)
{
cbd->cyan_red[cbd->application_mode] = adjustment->value;
color_balance_update (cbd, CR_TEXT);
if (cbd->preview)
color_balance_preview (cbd);
}
}
static void
color_balance_mg_scale_update (GtkAdjustment *adjustment,
gpointer data)
{
ColorBalanceDialog *cbd;
cbd = (ColorBalanceDialog *) data;
if (cbd->magenta_green[cbd->application_mode] != adjustment->value)
{
cbd->magenta_green[cbd->application_mode] = adjustment->value;
color_balance_update (cbd, MG_TEXT);
if (cbd->preview)
color_balance_preview (cbd);
}
}
static void
color_balance_yb_scale_update (GtkAdjustment *adjustment,
gpointer data)
{
ColorBalanceDialog *cbd;
cbd = (ColorBalanceDialog *) data;
if (cbd->yellow_blue[cbd->application_mode] != adjustment->value)
{
cbd->yellow_blue[cbd->application_mode] = adjustment->value;
color_balance_update (cbd, YB_TEXT);
if (cbd->preview)
color_balance_preview (cbd);
}
}
static void
color_balance_cr_text_update (GtkWidget *w,
gpointer data)
{
ColorBalanceDialog *cbd;
char *str;
int value;
str = gtk_entry_get_text (GTK_ENTRY (w));
cbd = (ColorBalanceDialog *) data;
value = BOUNDS (((int) atof (str)), -100, 100);
if ((int) cbd->cyan_red[cbd->application_mode] != value)
{
cbd->cyan_red[cbd->application_mode] = value;
color_balance_update (cbd, CR_SLIDER);
if (cbd->preview)
color_balance_preview (cbd);
}
}
static void
color_balance_mg_text_update (GtkWidget *w,
gpointer data)
{
ColorBalanceDialog *cbd;
char *str;
int value;
str = gtk_entry_get_text (GTK_ENTRY (w));
cbd = (ColorBalanceDialog *) data;
value = BOUNDS (((int) atof (str)), -100, 100);
if ((int) cbd->magenta_green[cbd->application_mode] != value)
{
cbd->magenta_green[cbd->application_mode] = value;
color_balance_update (cbd, MG_SLIDER);
if (cbd->preview)
color_balance_preview (cbd);
}
}
static void
color_balance_yb_text_update (GtkWidget *w,
gpointer data)
{
ColorBalanceDialog *cbd;
char *str;
int value;
str = gtk_entry_get_text (GTK_ENTRY (w));
cbd = (ColorBalanceDialog *) data;
value = BOUNDS (((int) atof (str)), -100, 100);
if ((int) cbd->yellow_blue[cbd->application_mode] != value)
{
cbd->yellow_blue[cbd->application_mode] = value;
color_balance_update (cbd, YB_SLIDER);
if (cbd->preview)
color_balance_preview (cbd);
}
}