mirror of https://github.com/GNOME/gimp.git
app/gegl/Makefile.am app/gegl/gegl-types.h new config object.
2008-01-24 Michael Natterer <mitch@gimp.org> * app/gegl/Makefile.am * app/gegl/gegl-types.h * app/gegl/gimpcolorbalanceconfig.[ch]: new config object. * app/gegl/gimpoperationcolorbalance.[ch]: use it. * app/tools/gimpcolorbalancetool.[ch]: port to GimpColorBalanceConfig and use the old ColorBalance cruft only in map(). The effect of the GEGL operator is now even more different from the cruft code because I removed a hack that was applying an additional factor when mapping between the ColorBalance values and the new properties, but that was only a workaround to make it look more similar anyway. Will have to fix this properly. * app/base/color-balance.[ch]: remove API that is now obsolete. svn path=/trunk/; revision=24701
This commit is contained in:
parent
a9b946e376
commit
b25559c3e5
18
ChangeLog
18
ChangeLog
|
@ -1,3 +1,21 @@
|
|||
2008-01-24 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* app/gegl/Makefile.am
|
||||
* app/gegl/gegl-types.h
|
||||
* app/gegl/gimpcolorbalanceconfig.[ch]: new config object.
|
||||
|
||||
* app/gegl/gimpoperationcolorbalance.[ch]: use it.
|
||||
|
||||
* app/tools/gimpcolorbalancetool.[ch]: port to
|
||||
GimpColorBalanceConfig and use the old ColorBalance cruft only in
|
||||
map(). The effect of the GEGL operator is now even more different
|
||||
from the cruft code because I removed a hack that was applying an
|
||||
additional factor when mapping between the ColorBalance values and
|
||||
the new properties, but that was only a workaround to make it look
|
||||
more similar anyway. Will have to fix this properly.
|
||||
|
||||
* app/base/color-balance.[ch]: remove API that is now obsolete.
|
||||
|
||||
2008-01-24 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* app/core/gimpimage.c
|
||||
|
|
|
@ -59,22 +59,15 @@ color_balance_init (ColorBalance *cb)
|
|||
g_return_if_fail (cb != NULL);
|
||||
|
||||
for (range = GIMP_SHADOWS; range <= GIMP_HIGHLIGHTS; range++)
|
||||
color_balance_range_reset (cb, range);
|
||||
{
|
||||
cb->cyan_red[range] = 0.0;
|
||||
cb->magenta_green[range] = 0.0;
|
||||
cb->yellow_blue[range] = 0.0;
|
||||
}
|
||||
|
||||
cb->preserve_luminosity = TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
color_balance_range_reset (ColorBalance *cb,
|
||||
GimpTransferMode range)
|
||||
{
|
||||
g_return_if_fail (cb != NULL);
|
||||
|
||||
cb->cyan_red[range] = 0.0;
|
||||
cb->magenta_green[range] = 0.0;
|
||||
cb->yellow_blue[range] = 0.0;
|
||||
}
|
||||
|
||||
void
|
||||
color_balance_create_lookup_tables (ColorBalance *cb)
|
||||
{
|
||||
|
|
|
@ -35,8 +35,6 @@ struct _ColorBalance
|
|||
|
||||
|
||||
void color_balance_init (ColorBalance *cb);
|
||||
void color_balance_range_reset (ColorBalance *cb,
|
||||
GimpTransferMode range);
|
||||
void color_balance_create_lookup_tables (ColorBalance *cb);
|
||||
void color_balance (ColorBalance *cb,
|
||||
PixelRegion *srcPR,
|
||||
|
|
|
@ -8,6 +8,8 @@ libappgegl_a_SOURCES = \
|
|||
gimp-gegl-utils.c \
|
||||
gimp-gegl-utils.h \
|
||||
\
|
||||
gimpcolorbalanceconfig.c \
|
||||
gimpcolorbalanceconfig.h \
|
||||
gimpcolorizeconfig.c \
|
||||
gimpcolorizeconfig.h \
|
||||
gimpcurvesconfig.c \
|
||||
|
|
|
@ -42,6 +42,7 @@ typedef struct _GimpOperationTileSource GimpOperationTileSource;
|
|||
|
||||
/* operation config objects */
|
||||
|
||||
typedef struct _GimpColorBalanceConfig GimpColorBalanceConfig;
|
||||
typedef struct _GimpColorizeConfig GimpColorizeConfig;
|
||||
typedef struct _GimpCurvesConfig GimpCurvesConfig;
|
||||
typedef struct _GimpHueSaturationConfig GimpHueSaturationConfig;
|
||||
|
|
|
@ -0,0 +1,245 @@
|
|||
/* GIMP - The GNU Image Manipulation Program
|
||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
*
|
||||
* gimpcolorbalanceconfig.c
|
||||
* Copyright (C) 2007 Michael Natterer <mitch@gimp.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <gegl.h>
|
||||
|
||||
#include "libgimpcolor/gimpcolor.h"
|
||||
#include "libgimpmath/gimpmath.h"
|
||||
|
||||
#include "gegl-types.h"
|
||||
|
||||
/* temp cruft */
|
||||
#include "base/color-balance.h"
|
||||
|
||||
#include "gimpcolorbalanceconfig.h"
|
||||
|
||||
|
||||
enum
|
||||
{
|
||||
PROP_0,
|
||||
PROP_RANGE,
|
||||
PROP_CYAN_RED,
|
||||
PROP_MAGENTA_GREEN,
|
||||
PROP_YELLOW_BLUE,
|
||||
PROP_PRESERVE_LUMINOSITY
|
||||
};
|
||||
|
||||
|
||||
static void gimp_color_balance_config_get_property (GObject *object,
|
||||
guint property_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec);
|
||||
static void gimp_color_balance_config_set_property (GObject *object,
|
||||
guint property_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec);
|
||||
|
||||
|
||||
G_DEFINE_TYPE (GimpColorBalanceConfig, gimp_color_balance_config,
|
||||
G_TYPE_OBJECT)
|
||||
|
||||
#define parent_class gimp_color_balance_config_parent_class
|
||||
|
||||
|
||||
static void
|
||||
gimp_color_balance_config_class_init (GimpColorBalanceConfigClass * klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
object_class->set_property = gimp_color_balance_config_set_property;
|
||||
object_class->get_property = gimp_color_balance_config_get_property;
|
||||
|
||||
g_object_class_install_property (object_class, PROP_RANGE,
|
||||
g_param_spec_enum ("range",
|
||||
"range",
|
||||
"The affected range",
|
||||
GIMP_TYPE_TRANSFER_MODE,
|
||||
GIMP_MIDTONES,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT));
|
||||
|
||||
g_object_class_install_property (object_class, PROP_CYAN_RED,
|
||||
g_param_spec_double ("cyan-red",
|
||||
"Cyan-Red",
|
||||
"Cyan-Red",
|
||||
-1.0, 1.0, 0.0,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT));
|
||||
|
||||
g_object_class_install_property (object_class, PROP_MAGENTA_GREEN,
|
||||
g_param_spec_double ("magenta-green",
|
||||
"Magenta-Green",
|
||||
"Magenta-Green",
|
||||
-1.0, 1.0, 0.0,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT));
|
||||
|
||||
g_object_class_install_property (object_class, PROP_YELLOW_BLUE,
|
||||
g_param_spec_double ("yellow-blue",
|
||||
"Yellow-Blue",
|
||||
"Yellow-Blue",
|
||||
-1.0, 1.0, 1.0,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT));
|
||||
|
||||
g_object_class_install_property (object_class, PROP_PRESERVE_LUMINOSITY,
|
||||
g_param_spec_boolean ("preserve-luminosity",
|
||||
"Preserve Luminosity",
|
||||
"Preserve Luminosity",
|
||||
TRUE,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT));
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_color_balance_config_init (GimpColorBalanceConfig *self)
|
||||
{
|
||||
gimp_color_balance_config_reset (self);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_color_balance_config_get_property (GObject *object,
|
||||
guint property_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GimpColorBalanceConfig *self = GIMP_COLOR_BALANCE_CONFIG (object);
|
||||
|
||||
switch (property_id)
|
||||
{
|
||||
case PROP_RANGE:
|
||||
g_value_set_enum (value, self->range);
|
||||
break;
|
||||
|
||||
case PROP_CYAN_RED:
|
||||
g_value_set_double (value, self->cyan_red[self->range]);
|
||||
break;
|
||||
|
||||
case PROP_MAGENTA_GREEN:
|
||||
g_value_set_double (value, self->magenta_green[self->range]);
|
||||
break;
|
||||
|
||||
case PROP_YELLOW_BLUE:
|
||||
g_value_set_double (value, self->yellow_blue[self->range]);
|
||||
break;
|
||||
|
||||
case PROP_PRESERVE_LUMINOSITY:
|
||||
g_value_set_boolean (value, self->preserve_luminosity);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_color_balance_config_set_property (GObject *object,
|
||||
guint property_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GimpColorBalanceConfig *self = GIMP_COLOR_BALANCE_CONFIG (object);
|
||||
|
||||
switch (property_id)
|
||||
{
|
||||
case PROP_RANGE:
|
||||
self->range = g_value_get_enum (value);
|
||||
break;
|
||||
|
||||
case PROP_CYAN_RED:
|
||||
self->cyan_red[self->range] = g_value_get_double (value);
|
||||
break;
|
||||
|
||||
case PROP_MAGENTA_GREEN:
|
||||
self->magenta_green[self->range] = g_value_get_double (value);
|
||||
break;
|
||||
|
||||
case PROP_YELLOW_BLUE:
|
||||
self->yellow_blue[self->range] = g_value_get_double (value);
|
||||
break;
|
||||
|
||||
case PROP_PRESERVE_LUMINOSITY:
|
||||
self->preserve_luminosity = g_value_get_boolean (value);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* public functions */
|
||||
|
||||
void
|
||||
gimp_color_balance_config_reset (GimpColorBalanceConfig *config)
|
||||
{
|
||||
GimpTransferMode range;
|
||||
|
||||
g_return_if_fail (GIMP_IS_COLOR_BALANCE_CONFIG (config));
|
||||
|
||||
config->range = GIMP_MIDTONES;
|
||||
|
||||
for (range = GIMP_SHADOWS; range <= GIMP_HIGHLIGHTS; range++)
|
||||
{
|
||||
gimp_color_balance_config_reset_range (config, range);
|
||||
}
|
||||
|
||||
config->preserve_luminosity = TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
gimp_color_balance_config_reset_range (GimpColorBalanceConfig *config,
|
||||
GimpTransferMode range)
|
||||
{
|
||||
g_return_if_fail (GIMP_IS_COLOR_BALANCE_CONFIG (config));
|
||||
|
||||
config->cyan_red[range] = 0.0;
|
||||
config->magenta_green[range] = 0.0;
|
||||
config->yellow_blue[range] = 0.0;
|
||||
}
|
||||
|
||||
|
||||
/* temp cruft */
|
||||
|
||||
void
|
||||
gimp_color_balance_config_to_cruft (GimpColorBalanceConfig *config,
|
||||
ColorBalance *cruft)
|
||||
{
|
||||
GimpTransferMode range;
|
||||
|
||||
g_return_if_fail (GIMP_IS_COLOR_BALANCE_CONFIG (config));
|
||||
g_return_if_fail (cruft != NULL);
|
||||
|
||||
for (range = GIMP_SHADOWS; range <= GIMP_HIGHLIGHTS; range++)
|
||||
{
|
||||
cruft->cyan_red[range] = config->cyan_red[range] * 100.0;
|
||||
cruft->magenta_green[range] = config->magenta_green[range] * 100.0;
|
||||
cruft->yellow_blue[range] = config->yellow_blue[range] * 100.0;
|
||||
}
|
||||
|
||||
cruft->preserve_luminosity = config->preserve_luminosity;
|
||||
|
||||
color_balance_create_lookup_tables (cruft);
|
||||
}
|
|
@ -0,0 +1,66 @@
|
|||
/* GIMP - The GNU Image Manipulation Program
|
||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
*
|
||||
* gimpcolorbalanceconfig.h
|
||||
* Copyright (C) 2007 Michael Natterer <mitch@gimp.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __GIMP_COLOR_BALANCE_CONFIG_H__
|
||||
#define __GIMP_COLOR_BALANCE_CONFIG_H__
|
||||
|
||||
|
||||
#define GIMP_TYPE_COLOR_BALANCE_CONFIG (gimp_color_balance_config_get_type ())
|
||||
#define GIMP_COLOR_BALANCE_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_COLOR_BALANCE_CONFIG, GimpColorBalanceConfig))
|
||||
#define GIMP_COLOR_BALANCE_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_COLOR_BALANCE_CONFIG, GimpColorBalanceConfigClass))
|
||||
#define GIMP_IS_COLOR_BALANCE_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_COLOR_BALANCE_CONFIG))
|
||||
#define GIMP_IS_COLOR_BALANCE_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_COLOR_BALANCE_CONFIG))
|
||||
#define GIMP_COLOR_BALANCE_CONFIG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_COLOR_BALANCE_CONFIG, GimpColorBalanceConfigClass))
|
||||
|
||||
|
||||
typedef struct _GimpColorBalanceConfigClass GimpColorBalanceConfigClass;
|
||||
|
||||
struct _GimpColorBalanceConfig
|
||||
{
|
||||
GObject parent_instance;
|
||||
|
||||
GimpTransferMode range;
|
||||
|
||||
gdouble cyan_red[3];
|
||||
gdouble magenta_green[3];
|
||||
gdouble yellow_blue[3];
|
||||
|
||||
gboolean preserve_luminosity;
|
||||
};
|
||||
|
||||
struct _GimpColorBalanceConfigClass
|
||||
{
|
||||
GObjectClass parent_class;
|
||||
};
|
||||
|
||||
|
||||
GType gimp_color_balance_config_get_type (void) G_GNUC_CONST;
|
||||
|
||||
void gimp_color_balance_config_reset (GimpColorBalanceConfig *config);
|
||||
void gimp_color_balance_config_reset_range (GimpColorBalanceConfig *config,
|
||||
GimpTransferMode range);
|
||||
|
||||
/* temp cruft */
|
||||
void gimp_color_balance_config_to_cruft (GimpColorBalanceConfig *config,
|
||||
ColorBalance *cruft);
|
||||
|
||||
|
||||
#endif /* __GIMP_COLOR_BALANCE_CONFIG_H__ */
|
|
@ -28,20 +28,18 @@
|
|||
|
||||
#include "gegl-types.h"
|
||||
|
||||
#include "gimpcolorbalanceconfig.h"
|
||||
#include "gimpoperationcolorbalance.h"
|
||||
|
||||
|
||||
enum
|
||||
{
|
||||
PROP_0,
|
||||
PROP_RANGE,
|
||||
PROP_CYAN_RED,
|
||||
PROP_MAGENTA_GREEN,
|
||||
PROP_YELLOW_BLUE,
|
||||
PROP_PRESERVE_LUMINOSITY
|
||||
PROP_CONFIG
|
||||
};
|
||||
|
||||
|
||||
static void gimp_operation_color_balance_finalize (GObject *object);
|
||||
static void gimp_operation_color_balance_get_property (GObject *object,
|
||||
guint property_id,
|
||||
GValue *value,
|
||||
|
@ -70,6 +68,7 @@ gimp_operation_color_balance_class_init (GimpOperationColorBalanceClass * klass)
|
|||
GeglOperationClass *operation_class = GEGL_OPERATION_CLASS (klass);
|
||||
GeglOperationPointFilterClass *point_class = GEGL_OPERATION_POINT_FILTER_CLASS (klass);
|
||||
|
||||
object_class->finalize = gimp_operation_color_balance_finalize;
|
||||
object_class->set_property = gimp_operation_color_balance_set_property;
|
||||
object_class->get_property = gimp_operation_color_balance_get_property;
|
||||
|
||||
|
@ -77,63 +76,32 @@ gimp_operation_color_balance_class_init (GimpOperationColorBalanceClass * klass)
|
|||
|
||||
gegl_operation_class_set_name (operation_class, "gimp-color-balance");
|
||||
|
||||
g_object_class_install_property (object_class, PROP_RANGE,
|
||||
g_param_spec_enum ("range",
|
||||
"range",
|
||||
"The affected range",
|
||||
GIMP_TYPE_TRANSFER_MODE,
|
||||
GIMP_MIDTONES,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT));
|
||||
|
||||
g_object_class_install_property (object_class, PROP_CYAN_RED,
|
||||
g_param_spec_double ("cyan-red",
|
||||
"Cyan-Red",
|
||||
"Cyan-Red",
|
||||
-1.0, 1.0, 0.0,
|
||||
g_object_class_install_property (object_class, PROP_CONFIG,
|
||||
g_param_spec_object ("config",
|
||||
"Config",
|
||||
"The config object",
|
||||
GIMP_TYPE_COLOR_BALANCE_CONFIG,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT));
|
||||
|
||||
g_object_class_install_property (object_class, PROP_MAGENTA_GREEN,
|
||||
g_param_spec_double ("magenta-green",
|
||||
"Magenta-Green",
|
||||
"Magenta-Green",
|
||||
-1.0, 1.0, 0.0,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT));
|
||||
|
||||
g_object_class_install_property (object_class, PROP_YELLOW_BLUE,
|
||||
g_param_spec_double ("yellow-blue",
|
||||
"Yellow-Blue",
|
||||
"Yellow-Blue",
|
||||
-1.0, 1.0, 1.0,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT));
|
||||
|
||||
g_object_class_install_property (object_class, PROP_PRESERVE_LUMINOSITY,
|
||||
g_param_spec_boolean ("preserve-luminosity",
|
||||
"Preserve Luminosity",
|
||||
"Preserve Luminosity",
|
||||
TRUE,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT));
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_operation_color_balance_init (GimpOperationColorBalance *self)
|
||||
{
|
||||
GimpTransferMode range;
|
||||
}
|
||||
|
||||
self->range = GIMP_MIDTONES;
|
||||
static void
|
||||
gimp_operation_color_balance_finalize (GObject *object)
|
||||
{
|
||||
GimpOperationColorBalance *self = GIMP_OPERATION_COLOR_BALANCE (object);
|
||||
|
||||
for (range = GIMP_SHADOWS; range <= GIMP_HIGHLIGHTS; range++)
|
||||
if (self->config)
|
||||
{
|
||||
self->cyan_red[range] = 0.0;
|
||||
self->magenta_green[range] = 0.0;
|
||||
self->yellow_blue[range] = 0.0;
|
||||
g_object_unref (self->config);
|
||||
self->config = NULL;
|
||||
}
|
||||
|
||||
self->preserve_luminosity = TRUE;
|
||||
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -146,24 +114,8 @@ gimp_operation_color_balance_get_property (GObject *object,
|
|||
|
||||
switch (property_id)
|
||||
{
|
||||
case PROP_RANGE:
|
||||
g_value_set_enum (value, self->range);
|
||||
break;
|
||||
|
||||
case PROP_CYAN_RED:
|
||||
g_value_set_double (value, self->cyan_red[self->range]);
|
||||
break;
|
||||
|
||||
case PROP_MAGENTA_GREEN:
|
||||
g_value_set_double (value, self->magenta_green[self->range]);
|
||||
break;
|
||||
|
||||
case PROP_YELLOW_BLUE:
|
||||
g_value_set_double (value, self->yellow_blue[self->range]);
|
||||
break;
|
||||
|
||||
case PROP_PRESERVE_LUMINOSITY:
|
||||
g_value_set_boolean (value, self->preserve_luminosity);
|
||||
case PROP_CONFIG:
|
||||
g_value_set_object (value, self->config);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -182,24 +134,10 @@ gimp_operation_color_balance_set_property (GObject *object,
|
|||
|
||||
switch (property_id)
|
||||
{
|
||||
case PROP_RANGE:
|
||||
self->range = g_value_get_enum (value);
|
||||
break;
|
||||
|
||||
case PROP_CYAN_RED:
|
||||
self->cyan_red[self->range] = g_value_get_double (value);
|
||||
break;
|
||||
|
||||
case PROP_MAGENTA_GREEN:
|
||||
self->magenta_green[self->range] = g_value_get_double (value);
|
||||
break;
|
||||
|
||||
case PROP_YELLOW_BLUE:
|
||||
self->yellow_blue[self->range] = g_value_get_double (value);
|
||||
break;
|
||||
|
||||
case PROP_PRESERVE_LUMINOSITY:
|
||||
self->preserve_luminosity = g_value_get_boolean (value);
|
||||
case PROP_CONFIG:
|
||||
if (self->config)
|
||||
g_object_unref (self->config);
|
||||
self->config = g_value_dup_object (value);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -250,11 +188,15 @@ gimp_operation_color_balance_process (GeglOperation *operation,
|
|||
void *out_buf,
|
||||
glong samples)
|
||||
{
|
||||
GimpOperationColorBalance *self = GIMP_OPERATION_COLOR_BALANCE (operation);
|
||||
gfloat *src = in_buf;
|
||||
gfloat *dest = out_buf;
|
||||
GimpOperationColorBalance *self = GIMP_OPERATION_COLOR_BALANCE (operation);
|
||||
GimpColorBalanceConfig *config = self->config;
|
||||
gfloat *src = in_buf;
|
||||
gfloat *dest = out_buf;
|
||||
glong sample;
|
||||
|
||||
if (! config)
|
||||
return FALSE;
|
||||
|
||||
for (sample = 0; sample < samples; sample++)
|
||||
{
|
||||
gfloat r = src[RED_PIX];
|
||||
|
@ -265,21 +207,21 @@ gimp_operation_color_balance_process (GeglOperation *operation,
|
|||
gfloat b_n;
|
||||
|
||||
r_n = gimp_operation_color_balance_map (r,
|
||||
self->cyan_red[GIMP_SHADOWS],
|
||||
self->cyan_red[GIMP_MIDTONES],
|
||||
self->cyan_red[GIMP_HIGHLIGHTS]);
|
||||
config->cyan_red[GIMP_SHADOWS],
|
||||
config->cyan_red[GIMP_MIDTONES],
|
||||
config->cyan_red[GIMP_HIGHLIGHTS]);
|
||||
|
||||
g_n = gimp_operation_color_balance_map (g,
|
||||
self->magenta_green[GIMP_SHADOWS],
|
||||
self->magenta_green[GIMP_MIDTONES],
|
||||
self->magenta_green[GIMP_HIGHLIGHTS]);
|
||||
config->magenta_green[GIMP_SHADOWS],
|
||||
config->magenta_green[GIMP_MIDTONES],
|
||||
config->magenta_green[GIMP_HIGHLIGHTS]);
|
||||
|
||||
b_n = gimp_operation_color_balance_map (b,
|
||||
self->yellow_blue[GIMP_SHADOWS],
|
||||
self->yellow_blue[GIMP_MIDTONES],
|
||||
self->yellow_blue[GIMP_HIGHLIGHTS]);
|
||||
config->yellow_blue[GIMP_SHADOWS],
|
||||
config->yellow_blue[GIMP_MIDTONES],
|
||||
config->yellow_blue[GIMP_HIGHLIGHTS]);
|
||||
|
||||
if (self->preserve_luminosity)
|
||||
if (config->preserve_luminosity)
|
||||
{
|
||||
GimpRGB rgb;
|
||||
GimpHSL hsl;
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#ifndef __GIMP_OPERATION_COLOR_BALANCE_H__
|
||||
#define __GIMP_OPERATION_COLOR_BALANCE_H__
|
||||
|
||||
|
||||
#include <gegl-plugin.h>
|
||||
#include <operation/gegl-operation-point-filter.h>
|
||||
|
||||
|
@ -40,13 +41,7 @@ struct _GimpOperationColorBalance
|
|||
{
|
||||
GeglOperationPointFilter parent_instance;
|
||||
|
||||
GimpTransferMode range;
|
||||
|
||||
gdouble cyan_red[3];
|
||||
gdouble magenta_green[3];
|
||||
gdouble yellow_blue[3];
|
||||
|
||||
gboolean preserve_luminosity;
|
||||
GimpColorBalanceConfig *config;
|
||||
};
|
||||
|
||||
struct _GimpOperationColorBalanceClass
|
||||
|
|
|
@ -27,6 +27,8 @@
|
|||
|
||||
#include "base/color-balance.h"
|
||||
|
||||
#include "gegl/gimpcolorbalanceconfig.h"
|
||||
|
||||
#include "core/gimpdrawable.h"
|
||||
#include "core/gimpimage.h"
|
||||
#include "core/gimpimagemap.h"
|
||||
|
@ -116,7 +118,6 @@ gimp_color_balance_tool_init (GimpColorBalanceTool *cb_tool)
|
|||
GimpImageMapTool *im_tool = GIMP_IMAGE_MAP_TOOL (cb_tool);
|
||||
|
||||
cb_tool->color_balance = g_slice_new0 (ColorBalance);
|
||||
cb_tool->transfer_mode = GIMP_MIDTONES;
|
||||
|
||||
color_balance_init (cb_tool->color_balance);
|
||||
|
||||
|
@ -129,6 +130,12 @@ gimp_color_balance_tool_finalize (GObject *object)
|
|||
{
|
||||
GimpColorBalanceTool *cb_tool = GIMP_COLOR_BALANCE_TOOL (object);
|
||||
|
||||
if (cb_tool->config)
|
||||
{
|
||||
g_object_unref (cb_tool->config);
|
||||
cb_tool->config = NULL;
|
||||
}
|
||||
|
||||
g_slice_free (ColorBalance, cb_tool->color_balance);
|
||||
|
||||
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||
|
@ -154,12 +161,13 @@ gimp_color_balance_tool_initialize (GimpTool *tool,
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
color_balance_init (cb_tool->color_balance);
|
||||
|
||||
cb_tool->transfer_mode = GIMP_MIDTONES;
|
||||
gimp_color_balance_config_reset (cb_tool->config);
|
||||
|
||||
GIMP_TOOL_CLASS (parent_class)->initialize (tool, display, error);
|
||||
|
||||
gimp_int_radio_group_set_active (GTK_RADIO_BUTTON (cb_tool->range_radio),
|
||||
cb_tool->config->range);
|
||||
|
||||
color_balance_update (cb_tool);
|
||||
|
||||
return TRUE;
|
||||
|
@ -168,36 +176,28 @@ gimp_color_balance_tool_initialize (GimpTool *tool,
|
|||
static GeglNode *
|
||||
gimp_color_balance_tool_get_operation (GimpImageMapTool *im_tool)
|
||||
{
|
||||
return g_object_new (GEGL_TYPE_NODE,
|
||||
GimpColorBalanceTool *cb_tool = GIMP_COLOR_BALANCE_TOOL (im_tool);
|
||||
GeglNode *node;
|
||||
|
||||
node = g_object_new (GEGL_TYPE_NODE,
|
||||
"operation", "gimp-color-balance",
|
||||
NULL);
|
||||
|
||||
cb_tool->config = g_object_new (GIMP_TYPE_COLOR_BALANCE_CONFIG, NULL);
|
||||
|
||||
gegl_node_set (node,
|
||||
"config", cb_tool->config,
|
||||
NULL);
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_color_balance_tool_map (GimpImageMapTool *image_map_tool)
|
||||
{
|
||||
GimpColorBalanceTool *cb_tool = GIMP_COLOR_BALANCE_TOOL (image_map_tool);
|
||||
ColorBalance *cb = cb_tool->color_balance;
|
||||
GimpTransferMode range;
|
||||
|
||||
for (range = GIMP_SHADOWS; range <= GIMP_HIGHLIGHTS; range++)
|
||||
{
|
||||
gegl_node_set (image_map_tool->operation,
|
||||
"range", range,
|
||||
NULL);
|
||||
|
||||
gegl_node_set (image_map_tool->operation,
|
||||
"cyan-red", cb->cyan_red[range] / 256.0,
|
||||
"magenta-green", cb->magenta_green[range] / 256.0,
|
||||
"yellow-blue", cb->yellow_blue[range] / 256.0,
|
||||
NULL);
|
||||
}
|
||||
|
||||
gegl_node_set (image_map_tool->operation,
|
||||
"preserve-luminosity", cb->preserve_luminosity,
|
||||
NULL);
|
||||
|
||||
color_balance_create_lookup_tables (cb_tool->color_balance);
|
||||
gimp_color_balance_config_to_cruft (cb_tool->config, cb_tool->color_balance);
|
||||
}
|
||||
|
||||
|
||||
|
@ -252,7 +252,6 @@ gimp_color_balance_tool_dialog (GimpImageMapTool *im_tool)
|
|||
GtkWidget *vbox;
|
||||
GtkWidget *hbox;
|
||||
GtkWidget *table;
|
||||
GtkWidget *toggle;
|
||||
GtkWidget *button;
|
||||
GtkWidget *frame;
|
||||
|
||||
|
@ -260,7 +259,7 @@ gimp_color_balance_tool_dialog (GimpImageMapTool *im_tool)
|
|||
gtk_label_new (_("Select Range to Adjust")),
|
||||
G_CALLBACK (color_balance_range_callback),
|
||||
cb_tool,
|
||||
&toggle);
|
||||
&cb_tool->range_radio);
|
||||
gtk_box_pack_start (GTK_BOX (im_tool->main_vbox), frame, FALSE, FALSE, 0);
|
||||
gtk_widget_show (frame);
|
||||
|
||||
|
@ -279,22 +278,22 @@ gimp_color_balance_tool_dialog (GimpImageMapTool *im_tool)
|
|||
gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, FALSE, 0);
|
||||
gtk_widget_show (table);
|
||||
|
||||
cb_tool->cyan_red_adj =
|
||||
create_levels_scale (_("Cyan"), _("Red"), table, 0);
|
||||
cb_tool->cyan_red_adj = create_levels_scale (_("Cyan"), _("Red"),
|
||||
table, 0);
|
||||
|
||||
g_signal_connect (cb_tool->cyan_red_adj, "value-changed",
|
||||
G_CALLBACK (color_balance_cr_changed),
|
||||
cb_tool);
|
||||
|
||||
cb_tool->magenta_green_adj =
|
||||
create_levels_scale (_("Magenta"), _("Green"), table, 1);
|
||||
cb_tool->magenta_green_adj = create_levels_scale (_("Magenta"), _("Green"),
|
||||
table, 1);
|
||||
|
||||
g_signal_connect (cb_tool->magenta_green_adj, "value-changed",
|
||||
G_CALLBACK (color_balance_mg_changed),
|
||||
cb_tool);
|
||||
|
||||
cb_tool->yellow_blue_adj =
|
||||
create_levels_scale (_("Yellow"), _("Blue"), table, 2);
|
||||
cb_tool->yellow_blue_adj = create_levels_scale (_("Yellow"), _("Blue"),
|
||||
table, 2);
|
||||
|
||||
g_signal_connect (cb_tool->yellow_blue_adj, "value-changed",
|
||||
G_CALLBACK (color_balance_yb_changed),
|
||||
|
@ -315,7 +314,7 @@ gimp_color_balance_tool_dialog (GimpImageMapTool *im_tool)
|
|||
cb_tool->preserve_toggle =
|
||||
gtk_check_button_new_with_mnemonic (_("Preserve _luminosity"));
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (cb_tool->preserve_toggle),
|
||||
cb_tool->color_balance->preserve_luminosity);
|
||||
cb_tool->config->preserve_luminosity);
|
||||
gtk_box_pack_end (GTK_BOX (im_tool->main_vbox), cb_tool->preserve_toggle,
|
||||
FALSE, FALSE, 0);
|
||||
gtk_widget_show (cb_tool->preserve_toggle);
|
||||
|
@ -323,51 +322,62 @@ gimp_color_balance_tool_dialog (GimpImageMapTool *im_tool)
|
|||
g_signal_connect (cb_tool->preserve_toggle, "toggled",
|
||||
G_CALLBACK (color_balance_preserve_toggled),
|
||||
cb_tool);
|
||||
|
||||
/* set range after everything is in place */
|
||||
gimp_int_radio_group_set_active (GTK_RADIO_BUTTON (toggle),
|
||||
cb_tool->transfer_mode);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_color_balance_tool_reset (GimpImageMapTool *im_tool)
|
||||
{
|
||||
GimpColorBalanceTool *cb_tool = GIMP_COLOR_BALANCE_TOOL (im_tool);
|
||||
GimpTransferMode range = cb_tool->config->range;
|
||||
|
||||
gimp_color_balance_config_reset (cb_tool->config);
|
||||
g_object_set (cb_tool->config,
|
||||
"range", range,
|
||||
NULL);
|
||||
|
||||
color_balance_init (cb_tool->color_balance);
|
||||
color_balance_update (cb_tool);
|
||||
}
|
||||
|
||||
static void
|
||||
color_balance_update (GimpColorBalanceTool *cb_tool)
|
||||
{
|
||||
GimpTransferMode tm = cb_tool->transfer_mode;
|
||||
GimpColorBalanceConfig *config = cb_tool->config;
|
||||
|
||||
gtk_adjustment_set_value (cb_tool->cyan_red_adj,
|
||||
cb_tool->color_balance->cyan_red[tm]);
|
||||
config->cyan_red[config->range] * 100.0);
|
||||
gtk_adjustment_set_value (cb_tool->magenta_green_adj,
|
||||
cb_tool->color_balance->magenta_green[tm]);
|
||||
config->magenta_green[config->range] * 100.0);
|
||||
gtk_adjustment_set_value (cb_tool->yellow_blue_adj,
|
||||
cb_tool->color_balance->yellow_blue[tm]);
|
||||
config->yellow_blue[config->range] * 100.0);
|
||||
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (cb_tool->preserve_toggle),
|
||||
cb_tool->color_balance->preserve_luminosity);
|
||||
config->preserve_luminosity);
|
||||
}
|
||||
|
||||
static void
|
||||
color_balance_range_callback (GtkWidget *widget,
|
||||
GimpColorBalanceTool *cb_tool)
|
||||
{
|
||||
gimp_radio_button_update (widget, &cb_tool->transfer_mode);
|
||||
color_balance_update (cb_tool);
|
||||
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)))
|
||||
{
|
||||
GimpTransferMode range;
|
||||
|
||||
gimp_radio_button_update (widget, &range);
|
||||
g_object_set (cb_tool->config,
|
||||
"range", range,
|
||||
NULL);
|
||||
|
||||
color_balance_update (cb_tool);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
color_balance_range_reset_callback (GtkWidget *widget,
|
||||
GimpColorBalanceTool *cb_tool)
|
||||
{
|
||||
color_balance_range_reset (cb_tool->color_balance,
|
||||
cb_tool->transfer_mode);
|
||||
gimp_color_balance_config_reset_range (cb_tool->config,
|
||||
cb_tool->config->range);
|
||||
|
||||
color_balance_update (cb_tool);
|
||||
|
||||
gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (cb_tool));
|
||||
|
@ -377,11 +387,14 @@ static void
|
|||
color_balance_preserve_toggled (GtkWidget *widget,
|
||||
GimpColorBalanceTool *cb_tool)
|
||||
{
|
||||
gboolean active = GTK_TOGGLE_BUTTON (widget)->active;
|
||||
GimpColorBalanceConfig *config = cb_tool->config;
|
||||
gboolean active = GTK_TOGGLE_BUTTON (widget)->active;
|
||||
|
||||
if (cb_tool->color_balance->preserve_luminosity != active)
|
||||
if (config->preserve_luminosity != active)
|
||||
{
|
||||
cb_tool->color_balance->preserve_luminosity = active;
|
||||
g_object_set (config,
|
||||
"preserve-luminosity", active,
|
||||
NULL);
|
||||
|
||||
gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (cb_tool));
|
||||
}
|
||||
|
@ -391,11 +404,14 @@ static void
|
|||
color_balance_cr_changed (GtkAdjustment *adjustment,
|
||||
GimpColorBalanceTool *cb_tool)
|
||||
{
|
||||
GimpTransferMode tm = cb_tool->transfer_mode;
|
||||
GimpColorBalanceConfig *config = cb_tool->config;
|
||||
gdouble value = adjustment->value / 100.0;
|
||||
|
||||
if (cb_tool->color_balance->cyan_red[tm] != adjustment->value)
|
||||
if (config->cyan_red[config->range] != value)
|
||||
{
|
||||
cb_tool->color_balance->cyan_red[tm] = adjustment->value;
|
||||
g_object_set (config,
|
||||
"cyan-red", value,
|
||||
NULL);
|
||||
|
||||
gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (cb_tool));
|
||||
}
|
||||
|
@ -405,11 +421,14 @@ static void
|
|||
color_balance_mg_changed (GtkAdjustment *adjustment,
|
||||
GimpColorBalanceTool *cb_tool)
|
||||
{
|
||||
GimpTransferMode tm = cb_tool->transfer_mode;
|
||||
GimpColorBalanceConfig *config = cb_tool->config;
|
||||
gdouble value = adjustment->value / 100.0;
|
||||
|
||||
if (cb_tool->color_balance->magenta_green[tm] != adjustment->value)
|
||||
if (config->magenta_green[config->range] != value)
|
||||
{
|
||||
cb_tool->color_balance->magenta_green[tm] = adjustment->value;
|
||||
g_object_set (config,
|
||||
"magenta-green", value,
|
||||
NULL);
|
||||
|
||||
gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (cb_tool));
|
||||
}
|
||||
|
@ -419,11 +438,14 @@ static void
|
|||
color_balance_yb_changed (GtkAdjustment *adjustment,
|
||||
GimpColorBalanceTool *cb_tool)
|
||||
{
|
||||
GimpTransferMode tm = cb_tool->transfer_mode;
|
||||
GimpColorBalanceConfig *config = cb_tool->config;
|
||||
gdouble value = adjustment->value / 100.0;
|
||||
|
||||
if (cb_tool->color_balance->yellow_blue[tm] != adjustment->value)
|
||||
if (config->yellow_blue[config->range] != value)
|
||||
{
|
||||
cb_tool->color_balance->yellow_blue[tm] = adjustment->value;
|
||||
g_object_set (config,
|
||||
"yellow-blue", value,
|
||||
NULL);
|
||||
|
||||
gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (cb_tool));
|
||||
}
|
||||
|
|
|
@ -16,8 +16,8 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __GIMP_COLOR_BALANCE_DIALOG_H__
|
||||
#define __GIMP_COLOR_BALANCE_DIALOG_H__
|
||||
#ifndef __GIMP_COLOR_BALANCE_TOOL_H__
|
||||
#define __GIMP_COLOR_BALANCE_TOOL_H__
|
||||
|
||||
|
||||
#include "gimpimagemaptool.h"
|
||||
|
@ -37,16 +37,17 @@ typedef struct _GimpColorBalanceToolClass GimpColorBalanceToolClass;
|
|||
|
||||
struct _GimpColorBalanceTool
|
||||
{
|
||||
GimpImageMapTool parent_instance;
|
||||
GimpImageMapTool parent_instance;
|
||||
|
||||
ColorBalance *color_balance;
|
||||
GimpColorBalanceConfig *config;
|
||||
ColorBalance *color_balance;
|
||||
|
||||
/* dialog */
|
||||
GimpTransferMode transfer_mode;
|
||||
GtkAdjustment *cyan_red_adj;
|
||||
GtkAdjustment *magenta_green_adj;
|
||||
GtkAdjustment *yellow_blue_adj;
|
||||
GtkWidget *preserve_toggle;
|
||||
GtkWidget *range_radio;
|
||||
GtkAdjustment *cyan_red_adj;
|
||||
GtkAdjustment *magenta_green_adj;
|
||||
GtkAdjustment *yellow_blue_adj;
|
||||
GtkWidget *preserve_toggle;
|
||||
};
|
||||
|
||||
struct _GimpColorBalanceToolClass
|
||||
|
@ -61,4 +62,4 @@ void gimp_color_balance_tool_register (GimpToolRegisterCallback callback,
|
|||
GType gimp_color_balance_tool_get_type (void) G_GNUC_CONST;
|
||||
|
||||
|
||||
#endif /* __GIMP_COLOR_BALANCE_GIMP_H__ */
|
||||
#endif /* __GIMP_COLOR_BALANCE_TOOL_H__ */
|
||||
|
|
Loading…
Reference in New Issue