Bill Skaggs <weskaggs@primate.ucdavis.edu>

Merged 24710:24758 from trunk.

svn path=/branches/weskaggs/; revision=24761
This commit is contained in:
William Skaggs 2008-01-31 16:37:51 +00:00
parent bea345549b
commit 987aaf0b91
109 changed files with 3247 additions and 1753 deletions

View File

@ -1,3 +1,7 @@
2008-01-31 Bill Skaggs <weskaggs@primate.ucdavis.edu>
Merged 24710:24758 from trunk.
2008-01-31 Bill Skaggs <weskaggs@primate.ucdavis.edu>
* app/core/gimp.c: fix merge error from previous commit

View File

@ -400,7 +400,7 @@ tile_manager_map_tile (TileManager *tm,
if (G_UNLIKELY (num < 0))
{
g_warning ("%s: tile coordinates out of range.", G_GNUC_FUNCTION);
g_warning ("%s: tile coordinates out of range.", G_STRLOC);
return;
}
@ -427,13 +427,13 @@ tile_manager_map (TileManager *tm,
if (G_UNLIKELY ((tile_num < 0) || (tile_num >= ntiles)))
{
g_warning ("%s: tile out of range", G_GNUC_FUNCTION);
g_warning ("%s: tile out of range", G_STRLOC);
return;
}
if (G_UNLIKELY (! tm->tiles))
{
g_warning ("%s: empty tile level - initializing", G_GNUC_FUNCTION);
g_warning ("%s: empty tile level - initializing", G_STRLOC);
tm->tiles = g_new (Tile *, ntiles);
tiles = tm->tiles;
@ -475,14 +475,14 @@ tile_manager_map (TileManager *tm,
#endif
if (G_UNLIKELY (! srctile->valid))
g_warning("%s: srctile not validated yet! please report", G_GNUC_FUNCTION);
g_warning("%s: srctile not validated yet! please report", G_STRLOC);
if (G_UNLIKELY ((*tile_ptr)->ewidth != srctile->ewidth ||
(*tile_ptr)->eheight != srctile->eheight ||
(*tile_ptr)->bpp != srctile->bpp))
{
g_warning ("%s: nonconformant map (%p -> %p)",
G_GNUC_FUNCTION, srctile, *tile_ptr);
G_STRLOC, srctile, *tile_ptr);
}
tile_detach (*tile_ptr, tm, tile_num);
@ -645,7 +645,7 @@ tile_manager_get_tile_coordinates (TileManager *tm,
if (G_UNLIKELY (tl == NULL))
{
g_warning ("%s: tile not attached to manager", G_GNUC_FUNCTION);
g_warning ("%s: tile not attached to manager", G_STRLOC);
return;
}
@ -689,7 +689,7 @@ tile_manager_map_over_tile (TileManager *tm,
if (G_UNLIKELY (tl == NULL))
{
g_warning ("%s: tile not attached to manager", G_GNUC_FUNCTION);
g_warning ("%s: tile not attached to manager", G_STRLOC);
return;
}

View File

@ -67,6 +67,8 @@ keyboard_shortcuts_dialog_new (Gimp *gimp)
gtk_widget_show (vbox);
scrolled_window = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_window),
GTK_SHADOW_IN);
gtk_box_pack_start (GTK_BOX (vbox), scrolled_window, TRUE, TRUE, 0);

View File

@ -153,7 +153,6 @@ gimp_display_shell_autoscroll_timeout (gpointer data)
&x, &y, &width, &height);
gimp_display_shell_snap_coords (shell,
&image_coords,
&image_coords,
x, y, width, height);
}

View File

@ -663,7 +663,6 @@ gimp_display_shell_canvas_tool_events (GtkWidget *canvas,
&x, &y, &width, &height);
if (gimp_display_shell_snap_coords (shell,
&image_coords,
&image_coords,
x, y, width, height))
{
@ -1087,7 +1086,6 @@ gimp_display_shell_canvas_tool_events (GtkWidget *canvas,
&x, &y, &width, &height);
if (gimp_display_shell_snap_coords (shell,
&image_coords,
&image_coords,
x, y, width, height))
{
@ -1147,7 +1145,6 @@ gimp_display_shell_canvas_tool_events (GtkWidget *canvas,
&x, &y, &width, &height);
gimp_display_shell_snap_coords (shell,
&image_coords,
&image_coords,
x, y, width, height);
}
@ -1242,7 +1239,6 @@ gimp_display_shell_canvas_tool_events (GtkWidget *canvas,
&x, &y, &width, &height);
gimp_display_shell_snap_coords (shell,
&image_coords,
&image_coords,
x, y, width, height);
}

View File

@ -1227,12 +1227,12 @@ gimp_display_shell_get_unit (GimpDisplayShell *shell)
gboolean
gimp_display_shell_snap_coords (GimpDisplayShell *shell,
GimpCoords *coords,
GimpCoords *snapped_coords,
gint snap_offset_x,
gint snap_offset_y,
gint snap_width,
gint snap_height)
{
GimpImage *image;
gboolean snap_to_guides = FALSE;
gboolean snap_to_grid = FALSE;
gboolean snap_to_canvas = FALSE;
@ -1241,18 +1241,17 @@ gimp_display_shell_snap_coords (GimpDisplayShell *shell,
g_return_val_if_fail (GIMP_IS_DISPLAY_SHELL (shell), FALSE);
g_return_val_if_fail (coords != NULL, FALSE);
g_return_val_if_fail (snapped_coords != NULL, FALSE);
*snapped_coords = *coords;
image = shell->display->image;
if (gimp_display_shell_get_snap_to_guides (shell) &&
gimp_image_get_guides (shell->display->image))
gimp_image_get_guides (image))
{
snap_to_guides = TRUE;
}
if (gimp_display_shell_get_snap_to_grid (shell) &&
gimp_image_get_grid (shell->display->image))
gimp_image_get_grid (image))
{
snap_to_grid = TRUE;
}
@ -1260,18 +1259,17 @@ gimp_display_shell_snap_coords (GimpDisplayShell *shell,
snap_to_canvas = gimp_display_shell_get_snap_to_canvas (shell);
if (gimp_display_shell_get_snap_to_vectors (shell) &&
gimp_image_get_active_vectors (shell->display->image))
gimp_image_get_active_vectors (image))
{
snap_to_vectors = TRUE;
}
if (snap_to_guides || snap_to_grid || snap_to_canvas || snap_to_vectors)
{
gdouble tx, ty;
gint snap_distance;
gdouble tx, ty;
snap_distance =
GIMP_DISPLAY_CONFIG (shell->display->image->gimp->config)->snap_distance;
snap_distance = GIMP_DISPLAY_CONFIG (image->gimp->config)->snap_distance;
if (snap_width > 0 && snap_height > 0)
{
@ -1308,8 +1306,8 @@ gimp_display_shell_snap_coords (GimpDisplayShell *shell,
if (snapped)
{
snapped_coords->x = tx - snap_offset_x;
snapped_coords->y = ty - snap_offset_y;
coords->x = tx - snap_offset_x;
coords->y = ty - snap_offset_y;
}
}

View File

@ -221,7 +221,6 @@ GimpUnit gimp_display_shell_get_unit (GimpDisplayShell *shell);
gboolean gimp_display_shell_snap_coords (GimpDisplayShell *shell,
GimpCoords *coords,
GimpCoords *snapped_coords,
gint snap_offset_x,
gint snap_offset_y,
gint snap_width,

View File

@ -8,6 +8,8 @@ libappgegl_a_SOURCES = \
gimp-gegl-utils.c \
gimp-gegl-utils.h \
\
gimpbrightnesscontrastconfig.c \
gimpbrightnesscontrastconfig.h \
gimpcolorbalanceconfig.c \
gimpcolorbalanceconfig.h \
gimpcolorizeconfig.c \
@ -18,6 +20,8 @@ libappgegl_a_SOURCES = \
gimphuesaturationconfig.h \
gimplevelsconfig.c \
gimplevelsconfig.h \
gimpposterizeconfig.c \
gimpposterizeconfig.h \
gimpthresholdconfig.c \
gimpthresholdconfig.h \
\
@ -33,6 +37,8 @@ libappgegl_a_SOURCES = \
gimpoperationhuesaturation.h \
gimpoperationlevels.c \
gimpoperationlevels.h \
gimpoperationpointfilter.c \
gimpoperationpointfilter.h \
gimpoperationposterize.c \
gimpoperationposterize.h \
gimpoperationthreshold.c \

View File

@ -34,6 +34,7 @@ typedef struct _GimpOperationCurves GimpOperationCurves;
typedef struct _GimpOperationDesaturate GimpOperationDesaturate;
typedef struct _GimpOperationHueSaturation GimpOperationHueSaturation;
typedef struct _GimpOperationLevels GimpOperationLevels;
typedef struct _GimpOperationPointFilter GimpOperationPointFilter;
typedef struct _GimpOperationPosterize GimpOperationPosterize;
typedef struct _GimpOperationThreshold GimpOperationThreshold;
typedef struct _GimpOperationTileSink GimpOperationTileSink;
@ -42,11 +43,13 @@ typedef struct _GimpOperationTileSource GimpOperationTileSource;
/* operation config objects */
typedef struct _GimpBrightnessContrastConfig GimpBrightnessContrastConfig;
typedef struct _GimpColorBalanceConfig GimpColorBalanceConfig;
typedef struct _GimpColorizeConfig GimpColorizeConfig;
typedef struct _GimpCurvesConfig GimpCurvesConfig;
typedef struct _GimpHueSaturationConfig GimpHueSaturationConfig;
typedef struct _GimpLevelsConfig GimpLevelsConfig;
typedef struct _GimpPosterizeConfig GimpPosterizeConfig;
typedef struct _GimpThresholdConfig GimpThresholdConfig;

View File

@ -0,0 +1,159 @@
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimpbrightnesscontrastconfig.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 "libgimpconfig/gimpconfig.h"
#include "gegl-types.h"
#include "gimpbrightnesscontrastconfig.h"
enum
{
PROP_0,
PROP_BRIGHTNESS,
PROP_CONTRAST
};
static void gimp_brightness_contrast_config_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec);
static void gimp_brightness_contrast_config_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec);
G_DEFINE_TYPE_WITH_CODE (GimpBrightnessContrastConfig,
gimp_brightness_contrast_config,
G_TYPE_OBJECT,
G_IMPLEMENT_INTERFACE (GIMP_TYPE_CONFIG, NULL))
#define parent_class gimp_brightness_contrast_config_parent_class
static void
gimp_brightness_contrast_config_class_init (GimpBrightnessContrastConfigClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->set_property = gimp_brightness_contrast_config_set_property;
object_class->get_property = gimp_brightness_contrast_config_get_property;
g_object_class_install_property (object_class, PROP_BRIGHTNESS,
g_param_spec_double ("brightness",
"Brightness",
"Brightness",
-1.0, 1.0, 0.0,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT));
g_object_class_install_property (object_class, PROP_CONTRAST,
g_param_spec_double ("contrast",
"Contrast",
"Contrast",
-1.0, 1.0, 0.0,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT));
}
static void
gimp_brightness_contrast_config_init (GimpBrightnessContrastConfig *self)
{
}
static void
gimp_brightness_contrast_config_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
{
GimpBrightnessContrastConfig *self = GIMP_BRIGHTNESS_CONTRAST_CONFIG (object);
switch (property_id)
{
case PROP_BRIGHTNESS:
g_value_set_double (value, self->brightness);
break;
case PROP_CONTRAST:
g_value_set_double (value, self->contrast);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
gimp_brightness_contrast_config_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
GimpBrightnessContrastConfig *self = GIMP_BRIGHTNESS_CONTRAST_CONFIG (object);
switch (property_id)
{
case PROP_BRIGHTNESS:
self->brightness = g_value_get_double (value);
break;
case PROP_CONTRAST:
self->contrast = g_value_get_double (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
/* public functions */
void
gimp_brightness_contrast_config_set_node (GimpBrightnessContrastConfig *config,
GeglNode *node)
{
gdouble brightness;
gdouble contrast;
g_return_if_fail (GIMP_IS_BRIGHTNESS_CONTRAST_CONFIG (config));
g_return_if_fail (GEGL_IS_NODE (node));
brightness = config->brightness / 2.0;
contrast = (config->contrast < 0 ?
(config->contrast + 1.0) :
config->contrast * 4.0 + 1.0);
gegl_node_set (node,
"brightness", brightness,
"contrast", contrast,
NULL);
}

View File

@ -0,0 +1,56 @@
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimpbrightnesscontrastconfig.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_BRIGHTNESS_CONTRAST_CONFIG_H__
#define __GIMP_BRIGHTNESS_CONTRAST_CONFIG_H__
#define GIMP_TYPE_BRIGHTNESS_CONTRAST_CONFIG (gimp_brightness_contrast_config_get_type ())
#define GIMP_BRIGHTNESS_CONTRAST_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_BRIGHTNESS_CONTRAST_CONFIG, GimpBrightnessContrastConfig))
#define GIMP_BRIGHTNESS_CONTRAST_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_BRIGHTNESS_CONTRAST_CONFIG, GimpBrightnessContrastConfigClass))
#define GIMP_IS_BRIGHTNESS_CONTRAST_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_BRIGHTNESS_CONTRAST_CONFIG))
#define GIMP_IS_BRIGHTNESS_CONTRAST_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_BRIGHTNESS_CONTRAST_CONFIG))
#define GIMP_BRIGHTNESS_CONTRAST_CONFIG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_BRIGHTNESS_CONTRAST_CONFIG, GimpBrightnessContrastConfigClass))
typedef struct _GimpBrightnessContrastConfigClass GimpBrightnessContrastConfigClass;
struct _GimpBrightnessContrastConfig
{
GObject parent_instance;
gdouble brightness;
gdouble contrast;
};
struct _GimpBrightnessContrastConfigClass
{
GObjectClass parent_class;
};
GType gimp_brightness_contrast_config_get_type (void) G_GNUC_CONST;
void gimp_brightness_contrast_config_set_node (GimpBrightnessContrastConfig *config,
GeglNode *node);
#endif /* __GIMP_BRIGHTNESS_CONTRAST_CONFIG_H__ */

View File

@ -25,6 +25,7 @@
#include "libgimpcolor/gimpcolor.h"
#include "libgimpmath/gimpmath.h"
#include "libgimpconfig/gimpconfig.h"
#include "gegl-types.h"
@ -45,6 +46,8 @@ enum
};
static void gimp_color_balance_config_iface_init (GimpConfigInterface *iface);
static void gimp_color_balance_config_get_property (GObject *object,
guint property_id,
GValue *value,
@ -54,15 +57,19 @@ static void gimp_color_balance_config_set_property (GObject *object,
const GValue *value,
GParamSpec *pspec);
static void gimp_color_balance_config_reset (GimpConfig *config);
G_DEFINE_TYPE (GimpColorBalanceConfig, gimp_color_balance_config,
G_TYPE_OBJECT)
G_DEFINE_TYPE_WITH_CODE (GimpColorBalanceConfig, gimp_color_balance_config,
G_TYPE_OBJECT,
G_IMPLEMENT_INTERFACE (GIMP_TYPE_CONFIG,
gimp_color_balance_config_iface_init))
#define parent_class gimp_color_balance_config_parent_class
static void
gimp_color_balance_config_class_init (GimpColorBalanceConfigClass * klass)
gimp_color_balance_config_class_init (GimpColorBalanceConfigClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
@ -98,7 +105,7 @@ gimp_color_balance_config_class_init (GimpColorBalanceConfigClass * klass)
g_param_spec_double ("yellow-blue",
"Yellow-Blue",
"Yellow-Blue",
-1.0, 1.0, 1.0,
-1.0, 1.0, 0.0,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT));
@ -111,10 +118,16 @@ gimp_color_balance_config_class_init (GimpColorBalanceConfigClass * klass)
G_PARAM_CONSTRUCT));
}
static void
gimp_color_balance_config_iface_init (GimpConfigInterface *iface)
{
iface->reset = gimp_color_balance_config_reset;
}
static void
gimp_color_balance_config_init (GimpColorBalanceConfig *self)
{
gimp_color_balance_config_reset (self);
gimp_config_reset (GIMP_CONFIG (self));
}
static void
@ -165,6 +178,9 @@ gimp_color_balance_config_set_property (GObject *object,
{
case PROP_RANGE:
self->range = g_value_get_enum (value);
g_object_notify (object, "cyan-red");
g_object_notify (object, "magenta-green");
g_object_notify (object, "yellow-blue");
break;
case PROP_CYAN_RED:
@ -189,35 +205,41 @@ gimp_color_balance_config_set_property (GObject *object,
}
}
static void
gimp_color_balance_config_reset (GimpConfig *config)
{
GimpColorBalanceConfig *cb_config = GIMP_COLOR_BALANCE_CONFIG (config);
GimpTransferMode range;
g_object_freeze_notify (G_OBJECT (config));
for (range = GIMP_SHADOWS; range <= GIMP_HIGHLIGHTS; range++)
{
cb_config->range = range;
gimp_color_balance_config_reset_range (cb_config);
}
gimp_config_reset_property (G_OBJECT (config), "range");
gimp_config_reset_property (G_OBJECT (config), "preserve-luminosity");
g_object_thaw_notify (G_OBJECT (config));
}
/* 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)
gimp_color_balance_config_reset_range (GimpColorBalanceConfig *config)
{
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;
g_object_freeze_notify (G_OBJECT (config));
gimp_config_reset_property (G_OBJECT (config), "cyan-red");
gimp_config_reset_property (G_OBJECT (config), "magenta-green");
gimp_config_reset_property (G_OBJECT (config), "yellow-blue");
g_object_thaw_notify (G_OBJECT (config));
}

View File

@ -54,9 +54,7 @@ struct _GimpColorBalanceConfigClass
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);
void gimp_color_balance_config_reset_range (GimpColorBalanceConfig *config);
/* temp cruft */
void gimp_color_balance_config_to_cruft (GimpColorBalanceConfig *config,

View File

@ -23,6 +23,8 @@
#include <gegl.h>
#include "libgimpconfig/gimpconfig.h"
#include "gegl-types.h"
/* temp cruft */
@ -50,13 +52,15 @@ static void gimp_colorize_config_set_property (GObject *object,
GParamSpec *pspec);
G_DEFINE_TYPE (GimpColorizeConfig, gimp_colorize_config, G_TYPE_OBJECT)
G_DEFINE_TYPE_WITH_CODE (GimpColorizeConfig, gimp_colorize_config,
G_TYPE_OBJECT,
G_IMPLEMENT_INTERFACE (GIMP_TYPE_CONFIG, NULL))
#define parent_class gimp_colorize_config_parent_class
static void
gimp_colorize_config_class_init (GimpColorizeConfigClass * klass)
gimp_colorize_config_class_init (GimpColorizeConfigClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
@ -150,19 +154,6 @@ gimp_colorize_config_set_property (GObject *object,
}
/* public functions */
void
gimp_colorize_config_reset (GimpColorizeConfig *config)
{
g_return_if_fail (GIMP_IS_COLORIZE_CONFIG (config));
config->hue = 0.5;
config->saturation = 0.5;
config->lightness = 0.0;
}
/* temp cruft */
void

View File

@ -50,8 +50,6 @@ struct _GimpColorizeConfigClass
GType gimp_colorize_config_get_type (void) G_GNUC_CONST;
void gimp_colorize_config_reset (GimpColorizeConfig *config);
/* temp cruft */
void gimp_colorize_config_to_cruft (GimpColorizeConfig *config,
Colorize *cruft);

View File

@ -24,6 +24,7 @@
#include <string.h>
#include <gegl.h>
#include <glib/gstdio.h>
#include "libgimpcolor/gimpcolor.h"
#include "libgimpmath/gimpmath.h"
@ -49,6 +50,8 @@ enum
};
static void gimp_curves_config_iface_init (GimpConfigInterface *iface);
static void gimp_curves_config_finalize (GObject *object);
static void gimp_curves_config_get_property (GObject *object,
guint property_id,
@ -59,14 +62,22 @@ static void gimp_curves_config_set_property (GObject *object,
const GValue *value,
GParamSpec *pspec);
static void gimp_curves_config_reset (GimpConfig *config);
G_DEFINE_TYPE (GimpCurvesConfig, gimp_curves_config, G_TYPE_OBJECT)
static void gimp_curves_config_curve_dirty (GimpCurve *curve,
GimpCurvesConfig *config);
G_DEFINE_TYPE_WITH_CODE (GimpCurvesConfig, gimp_curves_config,
G_TYPE_OBJECT,
G_IMPLEMENT_INTERFACE (GIMP_TYPE_CONFIG,
gimp_curves_config_iface_init))
#define parent_class gimp_curves_config_parent_class
static void
gimp_curves_config_class_init (GimpCurvesConfigClass * klass)
gimp_curves_config_class_init (GimpCurvesConfigClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
@ -91,6 +102,12 @@ gimp_curves_config_class_init (GimpCurvesConfigClass * klass)
G_PARAM_READWRITE));
}
static void
gimp_curves_config_iface_init (GimpConfigInterface *iface)
{
iface->reset = gimp_curves_config_reset;
}
static void
gimp_curves_config_init (GimpCurvesConfig *self)
{
@ -101,9 +118,13 @@ gimp_curves_config_init (GimpCurvesConfig *self)
channel++)
{
self->curve[channel] = GIMP_CURVE (gimp_curve_new ("curves config"));
g_signal_connect_object (self->curve[channel], "dirty",
G_CALLBACK (gimp_curves_config_curve_dirty),
self, 0);
}
gimp_curves_config_reset (self);
gimp_config_reset (GIMP_CONFIG (self));
}
static void
@ -162,6 +183,7 @@ gimp_curves_config_set_property (GObject *object,
{
case PROP_CHANNEL:
self->channel = g_value_get_enum (value);
g_object_notify (object, "curve");
break;
case PROP_CURVE:
@ -176,33 +198,43 @@ gimp_curves_config_set_property (GObject *object,
}
}
/* public functions */
void
gimp_curves_config_reset (GimpCurvesConfig *config)
static void
gimp_curves_config_reset (GimpConfig *config)
{
GimpCurvesConfig *c_config = GIMP_CURVES_CONFIG (config);
GimpHistogramChannel channel;
g_return_if_fail (GIMP_IS_CURVES_CONFIG (config));
config->channel = GIMP_HISTOGRAM_VALUE;
g_object_freeze_notify (G_OBJECT (config));
for (channel = GIMP_HISTOGRAM_VALUE;
channel <= GIMP_HISTOGRAM_ALPHA;
channel++)
{
gimp_curve_reset (config->curve[channel], FALSE);
c_config->channel = channel;
gimp_curves_config_reset_channel (c_config);
}
gimp_config_reset_property (G_OBJECT (config), "channel");
g_object_thaw_notify (G_OBJECT (config));
}
static void
gimp_curves_config_curve_dirty (GimpCurve *curve,
GimpCurvesConfig *config)
{
g_object_notify (G_OBJECT (config), "curve");
}
/* public functions */
void
gimp_curves_config_reset_channel (GimpCurvesConfig *config,
GimpHistogramChannel channel)
gimp_curves_config_reset_channel (GimpCurvesConfig *config)
{
g_return_if_fail (GIMP_IS_CURVES_CONFIG (config));
gimp_curve_reset (config->curve[channel], FALSE);
gimp_curve_reset (config->curve[config->channel], TRUE);
}
gboolean
@ -245,6 +277,8 @@ gimp_curves_config_load_cruft (GimpCurvesConfig *config,
}
}
g_object_freeze_notify (G_OBJECT (config));
for (i = 0; i < 5; i++)
{
GimpCurve *curve = config->curve[i];
@ -259,6 +293,8 @@ gimp_curves_config_load_cruft (GimpCurvesConfig *config,
gimp_data_thaw (GIMP_DATA (curve));
}
g_object_thaw_notify (G_OBJECT (config));
return TRUE;
}

View File

@ -55,9 +55,7 @@ struct _GimpCurvesConfigClass
GType gimp_curves_config_get_type (void) G_GNUC_CONST;
void gimp_curves_config_reset (GimpCurvesConfig *config);
void gimp_curves_config_reset_channel (GimpCurvesConfig *config,
GimpHistogramChannel channel);
void gimp_curves_config_reset_channel (GimpCurvesConfig *config);
gboolean gimp_curves_config_load_cruft (GimpCurvesConfig *config,
gpointer fp,

View File

@ -23,6 +23,8 @@
#include <gegl.h>
#include "libgimpconfig/gimpconfig.h"
#include "gegl-types.h"
/* temp cruft */
@ -42,6 +44,8 @@ enum
};
static void gimp_hue_saturation_config_iface_init (GimpConfigInterface *iface);
static void gimp_hue_saturation_config_get_property (GObject *object,
guint property_id,
GValue *value,
@ -51,15 +55,19 @@ static void gimp_hue_saturation_config_set_property (GObject *object,
const GValue *value,
GParamSpec *pspec);
static void gimp_hue_saturation_config_reset (GimpConfig *config);
G_DEFINE_TYPE (GimpHueSaturationConfig, gimp_hue_saturation_config,
G_TYPE_OBJECT)
G_DEFINE_TYPE_WITH_CODE (GimpHueSaturationConfig, gimp_hue_saturation_config,
G_TYPE_OBJECT,
G_IMPLEMENT_INTERFACE (GIMP_TYPE_CONFIG,
gimp_hue_saturation_config_iface_init))
#define parent_class gimp_hue_saturation_config_parent_class
static void
gimp_hue_saturation_config_class_init (GimpHueSaturationConfigClass * klass)
gimp_hue_saturation_config_class_init (GimpHueSaturationConfigClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
@ -108,10 +116,16 @@ gimp_hue_saturation_config_class_init (GimpHueSaturationConfigClass * klass)
G_PARAM_CONSTRUCT));
}
static void
gimp_hue_saturation_config_iface_init (GimpConfigInterface *iface)
{
iface->reset = gimp_hue_saturation_config_reset;
}
static void
gimp_hue_saturation_config_init (GimpHueSaturationConfig *self)
{
gimp_hue_saturation_config_reset (self);
gimp_config_reset (GIMP_CONFIG (self));
}
static void
@ -162,6 +176,9 @@ gimp_hue_saturation_config_set_property (GObject *object,
{
case PROP_RANGE:
self->range = g_value_get_enum (value);
g_object_notify (object, "hue");
g_object_notify (object, "saturation");
g_object_notify (object, "lightness");
break;
case PROP_HUE:
@ -186,35 +203,41 @@ gimp_hue_saturation_config_set_property (GObject *object,
}
}
static void
gimp_hue_saturation_config_reset (GimpConfig *config)
{
GimpHueSaturationConfig *hs_config = GIMP_HUE_SATURATION_CONFIG (config);
GimpHueRange range;
g_object_freeze_notify (G_OBJECT (config));
for (range = GIMP_ALL_HUES; range <= GIMP_MAGENTA_HUES; range++)
{
hs_config->range = range;
gimp_hue_saturation_config_reset_range (hs_config);
}
gimp_config_reset_property (G_OBJECT (config), "range");
gimp_config_reset_property (G_OBJECT (config), "overlap");
g_object_thaw_notify (G_OBJECT (config));
}
/* public functions */
void
gimp_hue_saturation_config_reset (GimpHueSaturationConfig *config)
{
GimpHueRange range;
g_return_if_fail (GIMP_IS_HUE_SATURATION_CONFIG (config));
config->range = GIMP_ALL_HUES;
for (range = GIMP_ALL_HUES; range <= GIMP_MAGENTA_HUES; range++)
{
gimp_hue_saturation_config_reset_range (config, range);
}
config->overlap = 0.0;
}
void
gimp_hue_saturation_config_reset_range (GimpHueSaturationConfig *config,
GimpHueRange range)
gimp_hue_saturation_config_reset_range (GimpHueSaturationConfig *config)
{
g_return_if_fail (GIMP_IS_HUE_SATURATION_CONFIG (config));
config->hue[range] = 0.0;
config->saturation[range] = 0.0;
config->lightness[range] = 0.0;
g_object_freeze_notify (G_OBJECT (config));
gimp_config_reset_property (G_OBJECT (config), "hue");
gimp_config_reset_property (G_OBJECT (config), "saturation");
gimp_config_reset_property (G_OBJECT (config), "lightness");
g_object_thaw_notify (G_OBJECT (config));
}

View File

@ -54,9 +54,7 @@ struct _GimpHueSaturationConfigClass
GType gimp_hue_saturation_config_get_type (void) G_GNUC_CONST;
void gimp_hue_saturation_config_reset (GimpHueSaturationConfig *config);
void gimp_hue_saturation_config_reset_range (GimpHueSaturationConfig *config,
GimpHueRange range);
void gimp_hue_saturation_config_reset_range (GimpHueSaturationConfig *config);
/* temp cruft */
void gimp_hue_saturation_config_to_cruft (GimpHueSaturationConfig *config,

View File

@ -55,6 +55,8 @@ enum
};
static void gimp_levels_config_iface_init (GimpConfigInterface *iface);
static void gimp_levels_config_get_property (GObject *object,
guint property_id,
GValue *value,
@ -64,14 +66,19 @@ static void gimp_levels_config_set_property (GObject *object,
const GValue *value,
GParamSpec *pspec);
static void gimp_levels_config_reset (GimpConfig *config);
G_DEFINE_TYPE (GimpLevelsConfig, gimp_levels_config, G_TYPE_OBJECT)
G_DEFINE_TYPE_WITH_CODE (GimpLevelsConfig, gimp_levels_config,
G_TYPE_OBJECT,
G_IMPLEMENT_INTERFACE (GIMP_TYPE_CONFIG,
gimp_levels_config_iface_init))
#define parent_class gimp_levels_config_parent_class
static void
gimp_levels_config_class_init (GimpLevelsConfigClass * klass)
gimp_levels_config_class_init (GimpLevelsConfigClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
@ -128,10 +135,16 @@ gimp_levels_config_class_init (GimpLevelsConfigClass * klass)
G_PARAM_CONSTRUCT));
}
static void
gimp_levels_config_iface_init (GimpConfigInterface *iface)
{
iface->reset = gimp_levels_config_reset;
}
static void
gimp_levels_config_init (GimpLevelsConfig *self)
{
gimp_levels_config_reset (self);
gimp_config_reset (GIMP_CONFIG (self));
}
static void
@ -186,6 +199,11 @@ gimp_levels_config_set_property (GObject *object,
{
case PROP_CHANNEL:
self->channel = g_value_get_enum (value);
g_object_notify (object, "gamma");
g_object_notify (object, "low-input");
g_object_notify (object, "high-input");
g_object_notify (object, "low-output");
g_object_notify (object, "high-output");
break;
case PROP_GAMMA:
@ -214,37 +232,44 @@ gimp_levels_config_set_property (GObject *object,
}
}
/* public functions */
void
gimp_levels_config_reset (GimpLevelsConfig *config)
static void
gimp_levels_config_reset (GimpConfig *config)
{
GimpLevelsConfig *l_config = GIMP_LEVELS_CONFIG (config);
GimpHistogramChannel channel;
g_return_if_fail (GIMP_IS_LEVELS_CONFIG (config));
config->channel = GIMP_HISTOGRAM_VALUE;
g_object_freeze_notify (G_OBJECT (config));
for (channel = GIMP_HISTOGRAM_VALUE;
channel <= GIMP_HISTOGRAM_ALPHA;
channel++)
{
gimp_levels_config_reset_channel (config, channel);
l_config->channel = channel;
gimp_levels_config_reset_channel (l_config);
}
gimp_config_reset_property (G_OBJECT (config), "channel");
g_object_thaw_notify (G_OBJECT (config));
}
/* public functions */
void
gimp_levels_config_reset_channel (GimpLevelsConfig *config,
GimpHistogramChannel channel)
gimp_levels_config_reset_channel (GimpLevelsConfig *config)
{
g_return_if_fail (GIMP_IS_LEVELS_CONFIG (config));
config->gamma[channel] = 1.0;
config->low_input[channel] = 0.0;
config->high_input[channel] = 1.0;
config->low_output[channel] = 0.0;
config->high_output[channel] = 1.0;
g_object_freeze_notify (G_OBJECT (config));
gimp_config_reset_property (G_OBJECT (config), "gamma");
gimp_config_reset_property (G_OBJECT (config), "low-input");
gimp_config_reset_property (G_OBJECT (config), "high-input");
gimp_config_reset_property (G_OBJECT (config), "low-output");
gimp_config_reset_property (G_OBJECT (config), "high-output");
g_object_thaw_notify (G_OBJECT (config));
}
void
@ -255,23 +280,32 @@ gimp_levels_config_stretch (GimpLevelsConfig *config,
g_return_if_fail (GIMP_IS_LEVELS_CONFIG (config));
g_return_if_fail (histogram != NULL);
g_object_freeze_notify (G_OBJECT (config));
if (is_color)
{
GimpHistogramChannel channel;
/* Set the overall value to defaults */
gimp_levels_config_reset_channel (config, GIMP_HISTOGRAM_VALUE);
channel = config->channel;
config->channel = GIMP_HISTOGRAM_VALUE;
gimp_levels_config_reset_channel (config);
config->channel = channel;
for (channel = GIMP_HISTOGRAM_RED;
channel <= GIMP_HISTOGRAM_BLUE;
channel++)
{
gimp_levels_config_stretch_channel (config, histogram, channel);
}
}
else
{
gimp_levels_config_stretch_channel (config, histogram,
GIMP_HISTOGRAM_VALUE);
}
g_object_thaw_notify (G_OBJECT (config));
}
void
@ -285,6 +319,8 @@ gimp_levels_config_stretch_channel (GimpLevelsConfig *config,
g_return_if_fail (GIMP_IS_LEVELS_CONFIG (config));
g_return_if_fail (histogram != NULL);
g_object_freeze_notify (G_OBJECT (config));
config->gamma[channel] = 1.0;
config->low_output[channel] = 0.0;
config->high_output[channel] = 1.0;
@ -340,6 +376,14 @@ gimp_levels_config_stretch_channel (GimpLevelsConfig *config,
}
}
}
g_object_notify (G_OBJECT (config), "gamma");
g_object_notify (G_OBJECT (config), "low-input");
g_object_notify (G_OBJECT (config), "high-input");
g_object_notify (G_OBJECT (config), "low-output");
g_object_notify (G_OBJECT (config), "high-output");
g_object_thaw_notify (G_OBJECT (config));
}
static gdouble
@ -379,13 +423,22 @@ gimp_levels_config_adjust_by_colors (GimpLevelsConfig *config,
{
g_return_if_fail (GIMP_IS_LEVELS_CONFIG (config));
g_object_freeze_notify (G_OBJECT (config));
if (black)
{
config->low_input[channel] = gimp_levels_config_input_from_color (channel,
black);
g_object_notify (G_OBJECT (config), "low-input");
}
if (white)
{
config->high_input[channel] = gimp_levels_config_input_from_color (channel,
white);
g_object_notify (G_OBJECT (config), "high-input");
}
if (gray)
{
@ -417,7 +470,10 @@ gimp_levels_config_adjust_by_colors (GimpLevelsConfig *config,
/* Map selected color to corresponding lightness */
config->gamma[channel] = log (inten) / log (out_light);
g_object_notify (G_OBJECT (config), "gamma");
}
g_object_thaw_notify (G_OBJECT (config));
}
gboolean
@ -468,6 +524,8 @@ gimp_levels_config_load_cruft (GimpLevelsConfig *config,
goto error;
}
g_object_freeze_notify (G_OBJECT (config));
for (i = 0; i < 5; i++)
{
config->low_input[i] = low_input[i] / 255.0;
@ -477,6 +535,14 @@ gimp_levels_config_load_cruft (GimpLevelsConfig *config,
config->gamma[i] = gamma[i];
}
g_object_notify (G_OBJECT (config), "gamma");
g_object_notify (G_OBJECT (config), "low-input");
g_object_notify (G_OBJECT (config), "high-input");
g_object_notify (G_OBJECT (config), "low-output");
g_object_notify (G_OBJECT (config), "high-output");
g_object_thaw_notify (G_OBJECT (config));
return TRUE;
error:

View File

@ -56,9 +56,7 @@ struct _GimpLevelsConfigClass
GType gimp_levels_config_get_type (void) G_GNUC_CONST;
void gimp_levels_config_reset (GimpLevelsConfig *config);
void gimp_levels_config_reset_channel (GimpLevelsConfig *config,
GimpHistogramChannel channel);
void gimp_levels_config_reset_channel (GimpLevelsConfig *config);
void gimp_levels_config_stretch (GimpLevelsConfig *config,
GimpHistogram *histogram,

View File

@ -32,23 +32,6 @@
#include "gimpoperationcolorbalance.h"
enum
{
PROP_0,
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,
GParamSpec *pspec);
static void gimp_operation_color_balance_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec);
static gboolean gimp_operation_color_balance_process (GeglOperation *operation,
void *in_buf,
void *out_buf,
@ -56,27 +39,27 @@ static gboolean gimp_operation_color_balance_process (GeglOperation *operat
G_DEFINE_TYPE (GimpOperationColorBalance, gimp_operation_color_balance,
GEGL_TYPE_OPERATION_POINT_FILTER)
GIMP_TYPE_OPERATION_POINT_FILTER)
#define parent_class gimp_operation_color_balance_parent_class
static void
gimp_operation_color_balance_class_init (GimpOperationColorBalanceClass * klass)
gimp_operation_color_balance_class_init (GimpOperationColorBalanceClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (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;
object_class->set_property = gimp_operation_point_filter_set_property;
object_class->get_property = gimp_operation_point_filter_get_property;
operation_class->name = "gimp-color-balance";
point_class->process = gimp_operation_color_balance_process;
gegl_operation_class_set_name (operation_class, "gimp-color-balance");
g_object_class_install_property (object_class, PROP_CONFIG,
g_object_class_install_property (object_class,
GIMP_OPERATION_POINT_FILTER_PROP_CONFIG,
g_param_spec_object ("config",
"Config",
"The config object",
@ -90,62 +73,6 @@ gimp_operation_color_balance_init (GimpOperationColorBalance *self)
{
}
static void
gimp_operation_color_balance_finalize (GObject *object)
{
GimpOperationColorBalance *self = GIMP_OPERATION_COLOR_BALANCE (object);
if (self->config)
{
g_object_unref (self->config);
self->config = NULL;
}
G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
gimp_operation_color_balance_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
{
GimpOperationColorBalance *self = GIMP_OPERATION_COLOR_BALANCE (object);
switch (property_id)
{
case PROP_CONFIG:
g_value_set_object (value, self->config);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
gimp_operation_color_balance_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
GimpOperationColorBalance *self = GIMP_OPERATION_COLOR_BALANCE (object);
switch (property_id)
{
case PROP_CONFIG:
if (self->config)
g_object_unref (self->config);
self->config = g_value_dup_object (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static inline gfloat
gimp_operation_color_balance_map (gfloat value,
gdouble shadows,
@ -188,16 +115,15 @@ gimp_operation_color_balance_process (GeglOperation *operation,
void *out_buf,
glong samples)
{
GimpOperationColorBalance *self = GIMP_OPERATION_COLOR_BALANCE (operation);
GimpColorBalanceConfig *config = self->config;
GimpOperationPointFilter *point = GIMP_OPERATION_POINT_FILTER (operation);
GimpColorBalanceConfig *config = GIMP_COLOR_BALANCE_CONFIG (point->config);
gfloat *src = in_buf;
gfloat *dest = out_buf;
glong sample;
if (! config)
return FALSE;
for (sample = 0; sample < samples; sample++)
while (samples--)
{
gfloat r = src[RED_PIX];
gfloat g = src[GREEN_PIX];

View File

@ -23,8 +23,7 @@
#define __GIMP_OPERATION_COLOR_BALANCE_H__
#include <gegl-plugin.h>
#include <operation/gegl-operation-point-filter.h>
#include "gimpoperationpointfilter.h"
#define GIMP_TYPE_OPERATION_COLOR_BALANCE (gimp_operation_color_balance_get_type ())
@ -39,14 +38,12 @@ typedef struct _GimpOperationColorBalanceClass GimpOperationColorBalanceClass;
struct _GimpOperationColorBalance
{
GeglOperationPointFilter parent_instance;
GimpColorBalanceConfig *config;
GimpOperationPointFilter parent_instance;
};
struct _GimpOperationColorBalanceClass
{
GeglOperationPointFilterClass parent_class;
GimpOperationPointFilterClass parent_class;
};

View File

@ -31,23 +31,6 @@
#include "gimpoperationcolorize.h"
enum
{
PROP_0,
PROP_CONFIG
};
static void gimp_operation_colorize_finalize (GObject *object);
static void gimp_operation_colorize_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec);
static void gimp_operation_colorize_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec);
static gboolean gimp_operation_colorize_process (GeglOperation *operation,
void *in_buf,
void *out_buf,
@ -55,27 +38,27 @@ static gboolean gimp_operation_colorize_process (GeglOperation *operation,
G_DEFINE_TYPE (GimpOperationColorize, gimp_operation_colorize,
GEGL_TYPE_OPERATION_POINT_FILTER)
GIMP_TYPE_OPERATION_POINT_FILTER)
#define parent_class gimp_operation_colorize_parent_class
static void
gimp_operation_colorize_class_init (GimpOperationColorizeClass * klass)
gimp_operation_colorize_class_init (GimpOperationColorizeClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GeglOperationClass *operation_class = GEGL_OPERATION_CLASS (klass);
GeglOperationPointFilterClass *point_class = GEGL_OPERATION_POINT_FILTER_CLASS (klass);
object_class->finalize = gimp_operation_colorize_finalize;
object_class->set_property = gimp_operation_colorize_set_property;
object_class->get_property = gimp_operation_colorize_get_property;
object_class->set_property = gimp_operation_point_filter_set_property;
object_class->get_property = gimp_operation_point_filter_get_property;
operation_class->name = "gimp-colorize";
point_class->process = gimp_operation_colorize_process;
gegl_operation_class_set_name (operation_class, "gimp-colorize");
g_object_class_install_property (object_class, PROP_CONFIG,
g_object_class_install_property (object_class,
GIMP_OPERATION_POINT_FILTER_PROP_CONFIG,
g_param_spec_object ("config",
"Config",
"The config object",
@ -89,79 +72,25 @@ gimp_operation_colorize_init (GimpOperationColorize *self)
{
}
static void
gimp_operation_colorize_finalize (GObject *object)
{
GimpOperationColorize *self = GIMP_OPERATION_COLORIZE (object);
if (self->config)
{
g_object_unref (self->config);
self->config = NULL;
}
G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
gimp_operation_colorize_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
{
GimpOperationColorize *self = GIMP_OPERATION_COLORIZE (object);
switch (property_id)
{
case PROP_CONFIG:
g_value_set_object (value, self->config);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
gimp_operation_colorize_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
GimpOperationColorize *self = GIMP_OPERATION_COLORIZE (object);
switch (property_id)
{
case PROP_CONFIG:
if (self->config)
g_object_unref (self->config);
self->config = g_value_dup_object (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static gboolean
gimp_operation_colorize_process (GeglOperation *operation,
void *in_buf,
void *out_buf,
glong samples)
{
GimpOperationColorize *self = GIMP_OPERATION_COLORIZE (operation);
GimpColorizeConfig *config = self->config;
GimpOperationPointFilter *point = GIMP_OPERATION_POINT_FILTER (operation);
GimpColorizeConfig *config = GIMP_COLORIZE_CONFIG (point->config);
gfloat *src = in_buf;
gfloat *dest = out_buf;
GimpHSL hsl;
glong sample;
if (! config)
return FALSE;
hsl.h = config->hue;
hsl.s = config->saturation;
for (sample = 0; sample < samples; sample++)
while (samples--)
{
GimpRGB rgb;
gfloat lum = GIMP_RGB_LUMINANCE (src[RED_PIX],

View File

@ -22,8 +22,8 @@
#ifndef __GIMP_OPERATION_COLORIZE_H__
#define __GIMP_OPERATION_COLORIZE_H__
#include <gegl-plugin.h>
#include <operation/gegl-operation-point-filter.h>
#include "gimpoperationpointfilter.h"
#define GIMP_TYPE_OPERATION_COLORIZE (gimp_operation_colorize_get_type ())
@ -38,14 +38,12 @@ typedef struct _GimpOperationColorizeClass GimpOperationColorizeClass;
struct _GimpOperationColorize
{
GeglOperationPointFilter parent_instance;
GimpColorizeConfig *config;
GimpOperationPointFilter parent_instance;
};
struct _GimpOperationColorizeClass
{
GeglOperationPointFilterClass parent_class;
GimpOperationPointFilterClass parent_class;
};

View File

@ -32,23 +32,6 @@
#include "gimpoperationcurves.h"
enum
{
PROP_0,
PROP_CONFIG
};
static void gimp_operation_curves_finalize (GObject *object);
static void gimp_operation_curves_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec);
static void gimp_operation_curves_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec);
static gboolean gimp_operation_curves_process (GeglOperation *operation,
void *in_buf,
void *out_buf,
@ -56,27 +39,27 @@ static gboolean gimp_operation_curves_process (GeglOperation *operation,
G_DEFINE_TYPE (GimpOperationCurves, gimp_operation_curves,
GEGL_TYPE_OPERATION_POINT_FILTER)
GIMP_TYPE_OPERATION_POINT_FILTER)
#define parent_class gimp_operation_curves_parent_class
static void
gimp_operation_curves_class_init (GimpOperationCurvesClass * klass)
gimp_operation_curves_class_init (GimpOperationCurvesClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GeglOperationClass *operation_class = GEGL_OPERATION_CLASS (klass);
GeglOperationPointFilterClass *point_class = GEGL_OPERATION_POINT_FILTER_CLASS (klass);
object_class->finalize = gimp_operation_curves_finalize;
object_class->set_property = gimp_operation_curves_set_property;
object_class->get_property = gimp_operation_curves_get_property;
object_class->set_property = gimp_operation_point_filter_set_property;
object_class->get_property = gimp_operation_point_filter_get_property;
operation_class->name = "gimp-curves";
point_class->process = gimp_operation_curves_process;
gegl_operation_class_set_name (operation_class, "gimp-curves");
g_object_class_install_property (object_class, PROP_CONFIG,
g_object_class_install_property (object_class,
GIMP_OPERATION_POINT_FILTER_PROP_CONFIG,
g_param_spec_object ("config",
"Config",
"The config object",
@ -90,62 +73,6 @@ gimp_operation_curves_init (GimpOperationCurves *self)
{
}
static void
gimp_operation_curves_finalize (GObject *object)
{
GimpOperationCurves *self = GIMP_OPERATION_CURVES (object);
if (self->config)
{
g_object_unref (self->config);
self->config = NULL;
}
G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
gimp_operation_curves_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
{
GimpOperationCurves *self = GIMP_OPERATION_CURVES (object);
switch (property_id)
{
case PROP_CONFIG:
g_value_set_object (value, self->config);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
gimp_operation_curves_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
GimpOperationCurves *self = GIMP_OPERATION_CURVES (object);
switch (property_id)
{
case PROP_CONFIG:
if (self->config)
g_object_unref (self->config);
self->config = g_value_dup_object (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static inline gdouble
gimp_operation_curves_map (gdouble value,
GimpCurve *curve)
@ -176,16 +103,15 @@ gimp_operation_curves_process (GeglOperation *operation,
void *out_buf,
glong samples)
{
GimpOperationCurves *self = GIMP_OPERATION_CURVES (operation);
GimpCurvesConfig *config = self->config;
GimpOperationPointFilter *point = GIMP_OPERATION_POINT_FILTER (operation);
GimpCurvesConfig *config = GIMP_CURVES_CONFIG (point->config);
gfloat *src = in_buf;
gfloat *dest = out_buf;
glong sample;
if (! config)
return FALSE;
for (sample = 0; sample < samples; sample++)
while (samples--)
{
gint channel;

View File

@ -23,8 +23,7 @@
#define __GIMP_OPERATION_CURVES_H__
#include <gegl-plugin.h>
#include <operation/gegl-operation-point-filter.h>
#include "gimpoperationpointfilter.h"
#define GIMP_TYPE_OPERATION_CURVES (gimp_operation_curves_get_type ())
@ -39,14 +38,12 @@ typedef struct _GimpOperationCurvesClass GimpOperationCurvesClass;
struct _GimpOperationCurves
{
GeglOperationPointFilter parent_instance;
GimpCurvesConfig *config;
GimpOperationPointFilter parent_instance;
};
struct _GimpOperationCurvesClass
{
GeglOperationPointFilterClass parent_class;
GimpOperationPointFilterClass parent_class;
};

View File

@ -59,7 +59,7 @@ G_DEFINE_TYPE (GimpOperationDesaturate, gimp_operation_desaturate,
static void
gimp_operation_desaturate_class_init (GimpOperationDesaturateClass * klass)
gimp_operation_desaturate_class_init (GimpOperationDesaturateClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GeglOperationClass *operation_class = GEGL_OPERATION_CLASS (klass);
@ -68,9 +68,9 @@ gimp_operation_desaturate_class_init (GimpOperationDesaturateClass * klass)
object_class->set_property = gimp_operation_desaturate_set_property;
object_class->get_property = gimp_operation_desaturate_get_property;
point_class->process = gimp_operation_desaturate_process;
operation_class->name = "gimp-desaturate";
gegl_operation_class_set_name (operation_class, "gimp-desaturate");
point_class->process = gimp_operation_desaturate_process;
g_object_class_install_property (object_class,
PROP_MODE,
@ -137,9 +137,8 @@ gimp_operation_desaturate_process (GeglOperation *operation,
GimpOperationDesaturate *self = GIMP_OPERATION_DESATURATE (operation);
gfloat *src = in_buf;
gfloat *dest = out_buf;
glong sample;
for (sample = 0; sample < samples; sample++)
while (samples--)
{
gfloat value = 0.0;

View File

@ -32,23 +32,6 @@
#include "gimpoperationhuesaturation.h"
enum
{
PROP_0,
PROP_CONFIG
};
static void gimp_operation_hue_saturation_finalize (GObject *object);
static void gimp_operation_hue_saturation_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec);
static void gimp_operation_hue_saturation_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec);
static gboolean gimp_operation_hue_saturation_process (GeglOperation *operation,
void *in_buf,
void *out_buf,
@ -56,27 +39,27 @@ static gboolean gimp_operation_hue_saturation_process (GeglOperation *opera
G_DEFINE_TYPE (GimpOperationHueSaturation, gimp_operation_hue_saturation,
GEGL_TYPE_OPERATION_POINT_FILTER)
GIMP_TYPE_OPERATION_POINT_FILTER)
#define parent_class gimp_operation_hue_saturation_parent_class
static void
gimp_operation_hue_saturation_class_init (GimpOperationHueSaturationClass * klass)
gimp_operation_hue_saturation_class_init (GimpOperationHueSaturationClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GeglOperationClass *operation_class = GEGL_OPERATION_CLASS (klass);
GeglOperationPointFilterClass *point_class = GEGL_OPERATION_POINT_FILTER_CLASS (klass);
object_class->finalize = gimp_operation_hue_saturation_finalize;
object_class->set_property = gimp_operation_hue_saturation_set_property;
object_class->get_property = gimp_operation_hue_saturation_get_property;
object_class->set_property = gimp_operation_point_filter_set_property;
object_class->get_property = gimp_operation_point_filter_get_property;
operation_class->name = "gimp-hue-saturation";
point_class->process = gimp_operation_hue_saturation_process;
gegl_operation_class_set_name (operation_class, "gimp-hue-saturation");
g_object_class_install_property (object_class, PROP_CONFIG,
g_object_class_install_property (object_class,
GIMP_OPERATION_POINT_FILTER_PROP_CONFIG,
g_param_spec_object ("config",
"Config",
"The config object",
@ -90,62 +73,6 @@ gimp_operation_hue_saturation_init (GimpOperationHueSaturation *self)
{
}
static void
gimp_operation_hue_saturation_finalize (GObject *object)
{
GimpOperationHueSaturation *self = GIMP_OPERATION_HUE_SATURATION (object);
if (self->config)
{
g_object_unref (self->config);
self->config = NULL;
}
G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
gimp_operation_hue_saturation_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
{
GimpOperationHueSaturation *self = GIMP_OPERATION_HUE_SATURATION (object);
switch (property_id)
{
case PROP_CONFIG:
g_value_set_object (value, self->config);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
gimp_operation_hue_saturation_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
GimpOperationHueSaturation *self = GIMP_OPERATION_HUE_SATURATION (object);
switch (property_id)
{
case PROP_CONFIG:
if (self->config)
g_object_unref (self->config);
self->config = g_value_dup_object (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static inline gdouble
map_hue (GimpHueSaturationConfig *config,
GimpHueRange range,
@ -200,14 +127,16 @@ gimp_operation_hue_saturation_process (GeglOperation *operation,
void *out_buf,
glong samples)
{
GimpOperationHueSaturation *self = GIMP_OPERATION_HUE_SATURATION (operation);
GimpHueSaturationConfig *config = self->config;
GimpOperationPointFilter *point = GIMP_OPERATION_POINT_FILTER (operation);
GimpHueSaturationConfig *config = GIMP_HUE_SATURATION_CONFIG (point->config);
gfloat *src = in_buf;
gfloat *dest = out_buf;
gfloat overlap = config->overlap / 2.0;
glong sample;
for (sample = 0; sample < samples; sample++)
if (! config)
return FALSE;
while (samples--)
{
GimpRGB rgb;
GimpHSL hsl;

View File

@ -22,8 +22,8 @@
#ifndef __GIMP_OPERATION_HUE_SATURATION_H__
#define __GIMP_OPERATION_HUE_SATURATION_H__
#include <gegl-plugin.h>
#include <operation/gegl-operation-point-filter.h>
#include "gimpoperationpointfilter.h"
#define GIMP_TYPE_OPERATION_HUE_SATURATION (gimp_operation_hue_saturation_get_type ())
@ -38,14 +38,12 @@ typedef struct _GimpOperationHueSaturationClass GimpOperationHueSaturationClass;
struct _GimpOperationHueSaturation
{
GeglOperationPointFilter parent_instance;
GimpHueSaturationConfig *config;
GimpOperationPointFilter parent_instance;
};
struct _GimpOperationHueSaturationClass
{
GeglOperationPointFilterClass parent_class;
GimpOperationPointFilterClass parent_class;
};

View File

@ -32,23 +32,6 @@
#include "gimpoperationlevels.h"
enum
{
PROP_0,
PROP_CONFIG
};
static void gimp_operation_levels_finalize (GObject *object);
static void gimp_operation_levels_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec);
static void gimp_operation_levels_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec);
static gboolean gimp_operation_levels_process (GeglOperation *operation,
void *in_buf,
void *out_buf,
@ -56,27 +39,27 @@ static gboolean gimp_operation_levels_process (GeglOperation *operation,
G_DEFINE_TYPE (GimpOperationLevels, gimp_operation_levels,
GEGL_TYPE_OPERATION_POINT_FILTER)
GIMP_TYPE_OPERATION_POINT_FILTER)
#define parent_class gimp_operation_levels_parent_class
static void
gimp_operation_levels_class_init (GimpOperationLevelsClass * klass)
gimp_operation_levels_class_init (GimpOperationLevelsClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GeglOperationClass *operation_class = GEGL_OPERATION_CLASS (klass);
GeglOperationPointFilterClass *point_class = GEGL_OPERATION_POINT_FILTER_CLASS (klass);
object_class->finalize = gimp_operation_levels_finalize;
object_class->set_property = gimp_operation_levels_set_property;
object_class->get_property = gimp_operation_levels_get_property;
object_class->set_property = gimp_operation_point_filter_set_property;
object_class->get_property = gimp_operation_point_filter_get_property;
operation_class->name = "gimp-levels";
point_class->process = gimp_operation_levels_process;
gegl_operation_class_set_name (operation_class, "gimp-levels");
g_object_class_install_property (object_class, PROP_CONFIG,
g_object_class_install_property (object_class,
GIMP_OPERATION_POINT_FILTER_PROP_CONFIG,
g_param_spec_object ("config",
"Config",
"The config object",
@ -90,62 +73,6 @@ gimp_operation_levels_init (GimpOperationLevels *self)
{
}
static void
gimp_operation_levels_finalize (GObject *object)
{
GimpOperationLevels *self = GIMP_OPERATION_LEVELS (object);
if (self->config)
{
g_object_unref (self->config);
self->config = NULL;
}
G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
gimp_operation_levels_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
{
GimpOperationLevels *self = GIMP_OPERATION_LEVELS (object);
switch (property_id)
{
case PROP_CONFIG:
g_value_set_object (value, self->config);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
gimp_operation_levels_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
GimpOperationLevels *self = GIMP_OPERATION_LEVELS (object);
switch (property_id)
{
case PROP_CONFIG:
if (self->config)
g_object_unref (self->config);
self->config = g_value_dup_object (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static inline gdouble
gimp_operation_levels_map (gdouble value,
gdouble gamma,
@ -183,16 +110,15 @@ gimp_operation_levels_process (GeglOperation *operation,
void *out_buf,
glong samples)
{
GimpOperationLevels *self = GIMP_OPERATION_LEVELS (operation);
GimpLevelsConfig *config = self->config;
GimpOperationPointFilter *point = GIMP_OPERATION_POINT_FILTER (operation);
GimpLevelsConfig *config = GIMP_LEVELS_CONFIG (point->config);
gfloat *src = in_buf;
gfloat *dest = out_buf;
glong sample;
if (! config)
return FALSE;
for (sample = 0; sample < samples; sample++)
while (samples--)
{
gint channel;
@ -252,4 +178,3 @@ gimp_operation_levels_map_input (GimpLevelsConfig *config,
return value;
}

View File

@ -23,8 +23,7 @@
#define __GIMP_OPERATION_LEVELS_H__
#include <gegl-plugin.h>
#include <operation/gegl-operation-point-filter.h>
#include "gimpoperationpointfilter.h"
#define GIMP_TYPE_OPERATION_LEVELS (gimp_operation_levels_get_type ())
@ -39,14 +38,12 @@ typedef struct _GimpOperationLevelsClass GimpOperationLevelsClass;
struct _GimpOperationLevels
{
GeglOperationPointFilter parent_instance;
GimpLevelsConfig *config;
GimpOperationPointFilter parent_instance;
};
struct _GimpOperationLevelsClass
{
GeglOperationPointFilterClass parent_class;
GimpOperationPointFilterClass parent_class;
};

View File

@ -0,0 +1,107 @@
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimpoperationpointfilter.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 "gegl-types.h"
#include "gimpoperationpointfilter.h"
static void gimp_operation_point_filter_finalize (GObject *object);
G_DEFINE_TYPE (GimpOperationPointFilter, gimp_operation_point_filter,
GEGL_TYPE_OPERATION_POINT_FILTER)
#define parent_class gimp_operation_point_filter_parent_class
static void
gimp_operation_point_filter_class_init (GimpOperationPointFilterClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->finalize = gimp_operation_point_filter_finalize;
}
static void
gimp_operation_point_filter_init (GimpOperationPointFilter *self)
{
}
static void
gimp_operation_point_filter_finalize (GObject *object)
{
GimpOperationPointFilter *self = GIMP_OPERATION_POINT_FILTER (object);
if (self->config)
{
g_object_unref (self->config);
self->config = NULL;
}
G_OBJECT_CLASS (parent_class)->finalize (object);
}
void
gimp_operation_point_filter_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
{
GimpOperationPointFilter *self = GIMP_OPERATION_POINT_FILTER (object);
switch (property_id)
{
case GIMP_OPERATION_POINT_FILTER_PROP_CONFIG:
g_value_set_object (value, self->config);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
void
gimp_operation_point_filter_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
GimpOperationPointFilter *self = GIMP_OPERATION_POINT_FILTER (object);
switch (property_id)
{
case GIMP_OPERATION_POINT_FILTER_PROP_CONFIG:
if (self->config)
g_object_unref (self->config);
self->config = g_value_dup_object (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}

View File

@ -0,0 +1,72 @@
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimpoperationpointfilter.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_OPERATION_POINT_FILTER_H__
#define __GIMP_OPERATION_POINT_FILTER_H__
#include <gegl-plugin.h>
#include <operation/gegl-operation-point-filter.h>
enum
{
GIMP_OPERATION_POINT_FILTER_PROP_0,
GIMP_OPERATION_POINT_FILTER_PROP_CONFIG
};
#define GIMP_TYPE_OPERATION_POINT_FILTER (gimp_operation_point_filter_get_type ())
#define GIMP_OPERATION_POINT_FILTER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_OPERATION_POINT_FILTER, GimpOperationPointFilter))
#define GIMP_OPERATION_POINT_FILTER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_OPERATION_POINT_FILTER, GimpOperationPointFilterClass))
#define GIMP_IS_OPERATION_POINT_FILTER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_OPERATION_POINT_FILTER))
#define GIMP_IS_OPERATION_POINT_FILTER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_OPERATION_POINT_FILTER))
#define GIMP_OPERATION_POINT_FILTER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_OPERATION_POINT_FILTER, GimpOperationPointFilterClass))
typedef struct _GimpOperationPointFilterClass GimpOperationPointFilterClass;
struct _GimpOperationPointFilter
{
GeglOperationPointFilter parent_instance;
GObject *config;
};
struct _GimpOperationPointFilterClass
{
GeglOperationPointFilterClass parent_class;
};
GType gimp_operation_point_filter_get_type (void) G_GNUC_CONST;
void gimp_operation_point_filter_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec);
void gimp_operation_point_filter_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec);
#endif /* __GIMP_OPERATION_POINT_FILTER_H__ */

View File

@ -29,24 +29,9 @@
#include "gegl-types.h"
#include "gimpoperationposterize.h"
#include "gimpposterizeconfig.h"
enum
{
PROP_0,
PROP_LEVELS
};
static void gimp_operation_posterize_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec);
static void gimp_operation_posterize_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec);
static gboolean gimp_operation_posterize_process (GeglOperation *operation,
void *in_buf,
void *out_buf,
@ -54,31 +39,31 @@ static gboolean gimp_operation_posterize_process (GeglOperation *operation,
G_DEFINE_TYPE (GimpOperationPosterize, gimp_operation_posterize,
GEGL_TYPE_OPERATION_POINT_FILTER)
GIMP_TYPE_OPERATION_POINT_FILTER)
#define parent_class gimp_operation_posterize_parent_class
static void
gimp_operation_posterize_class_init (GimpOperationPosterizeClass * klass)
gimp_operation_posterize_class_init (GimpOperationPosterizeClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GeglOperationClass *operation_class = GEGL_OPERATION_CLASS (klass);
GeglOperationPointFilterClass *point_class = GEGL_OPERATION_POINT_FILTER_CLASS (klass);
object_class->set_property = gimp_operation_posterize_set_property;
object_class->get_property = gimp_operation_posterize_get_property;
object_class->set_property = gimp_operation_point_filter_set_property;
object_class->get_property = gimp_operation_point_filter_get_property;
operation_class->name = "gimp-posterize";
point_class->process = gimp_operation_posterize_process;
gegl_operation_class_set_name (operation_class, "gimp-posterize");
g_object_class_install_property (object_class,
PROP_LEVELS,
g_param_spec_int ("levels",
"Levels",
"Posterize levels",
2, 256, 10,
GIMP_OPERATION_POINT_FILTER_PROP_CONFIG,
g_param_spec_object ("config",
"Config",
"The config object",
GIMP_TYPE_POSTERIZE_CONFIG,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT));
}
@ -88,59 +73,22 @@ gimp_operation_posterize_init (GimpOperationPosterize *self)
{
}
static void
gimp_operation_posterize_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
{
GimpOperationPosterize *self = GIMP_OPERATION_POSTERIZE (object);
switch (property_id)
{
case PROP_LEVELS:
g_value_set_int (value, self->levels);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
gimp_operation_posterize_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
GimpOperationPosterize *self = GIMP_OPERATION_POSTERIZE (object);
switch (property_id)
{
case PROP_LEVELS:
self->levels = g_value_get_int (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static gboolean
gimp_operation_posterize_process (GeglOperation *operation,
void *in_buf,
void *out_buf,
glong samples)
{
GimpOperationPosterize *self = GIMP_OPERATION_POSTERIZE (operation);
GimpOperationPointFilter *point = GIMP_OPERATION_POINT_FILTER (operation);
GimpPosterizeConfig *config = GIMP_POSTERIZE_CONFIG (point->config);
gfloat *src = in_buf;
gfloat *dest = out_buf;
gfloat levels = self->levels - 1.0;
glong sample;
gfloat levels = config->levels - 1.0;
for (sample = 0; sample < samples; sample++)
if (! config)
return FALSE;
while (samples--)
{
dest[RED_PIX] = RINT (src[RED_PIX] * levels) / levels;
dest[GREEN_PIX] = RINT (src[GREEN_PIX] * levels) / levels;

View File

@ -23,13 +23,14 @@
#define __GIMP_OPERATION_POSTERIZE_H__
#include <gegl-plugin.h>
#include <operation/gegl-operation-point-filter.h>
#include "gimpoperationpointfilter.h"
#define GIMP_TYPE_OPERATION_POSTERIZE (gimp_operation_posterize_get_type ())
#define GIMP_OPERATION_POSTERIZE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_OPERATION_POSTERIZE, GimpOperationPosterize))
#define GIMP_OPERATION_POSTERIZE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_OPERATION_POSTERIZE, GimpOperationPosterizeClass))
#define GIMP_IS_OPERATION_POSTERIZE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_OPERATION_POSTERIZE))
#define GIMP_IS_OPERATION_POSTERIZE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_OPERATION_POSTERIZE))
#define GIMP_OPERATION_POSTERIZE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_OPERATION_POSTERIZE, GimpOperationPosterizeClass))
@ -37,14 +38,12 @@ typedef struct _GimpOperationPosterizeClass GimpOperationPosterizeClass;
struct _GimpOperationPosterize
{
GeglOperationPointFilter parent_instance;
gint levels;
GimpOperationPointFilter parent_instance;
};
struct _GimpOperationPosterizeClass
{
GeglOperationPointFilterClass parent_class;
GimpOperationPointFilterClass parent_class;
};

View File

@ -31,23 +31,6 @@
#include "gimpthresholdconfig.h"
enum
{
PROP_0,
PROP_CONFIG
};
static void gimp_operation_threshold_finalize (GObject *object);
static void gimp_operation_threshold_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec);
static void gimp_operation_threshold_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec);
static gboolean gimp_operation_threshold_process (GeglOperation *operation,
void *in_buf,
void *out_buf,
@ -55,27 +38,27 @@ static gboolean gimp_operation_threshold_process (GeglOperation *operation,
G_DEFINE_TYPE (GimpOperationThreshold, gimp_operation_threshold,
GEGL_TYPE_OPERATION_POINT_FILTER)
GIMP_TYPE_OPERATION_POINT_FILTER)
#define parent_class gimp_operation_threshold_parent_class
static void
gimp_operation_threshold_class_init (GimpOperationThresholdClass * klass)
gimp_operation_threshold_class_init (GimpOperationThresholdClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GeglOperationClass *operation_class = GEGL_OPERATION_CLASS (klass);
GeglOperationPointFilterClass *point_class = GEGL_OPERATION_POINT_FILTER_CLASS (klass);
object_class->finalize = gimp_operation_threshold_finalize;
object_class->set_property = gimp_operation_threshold_set_property;
object_class->get_property = gimp_operation_threshold_get_property;
object_class->set_property = gimp_operation_point_filter_set_property;
object_class->get_property = gimp_operation_point_filter_get_property;
operation_class->name = "gimp-threshold";
point_class->process = gimp_operation_threshold_process;
gegl_operation_class_set_name (operation_class, "gimp-threshold");
g_object_class_install_property (object_class, PROP_CONFIG,
g_object_class_install_property (object_class,
GIMP_OPERATION_POINT_FILTER_PROP_CONFIG,
g_param_spec_object ("config",
"Config",
"The config object",
@ -89,78 +72,21 @@ gimp_operation_threshold_init (GimpOperationThreshold *self)
{
}
static void
gimp_operation_threshold_finalize (GObject *object)
{
GimpOperationThreshold *self = GIMP_OPERATION_THRESHOLD (object);
if (self->config)
{
g_object_unref (self->config);
self->config = NULL;
}
G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
gimp_operation_threshold_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
{
GimpOperationThreshold *self = GIMP_OPERATION_THRESHOLD (object);
switch (property_id)
{
case PROP_CONFIG:
g_value_set_object (value, self->config);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
gimp_operation_threshold_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
GimpOperationThreshold *self = GIMP_OPERATION_THRESHOLD (object);
switch (property_id)
{
case PROP_CONFIG:
if (self->config)
g_object_unref (self->config);
self->config = g_value_dup_object (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static gboolean
gimp_operation_threshold_process (GeglOperation *operation,
void *in_buf,
void *out_buf,
glong samples)
{
GimpOperationThreshold *self = GIMP_OPERATION_THRESHOLD (operation);
GimpThresholdConfig *config = self->config;
GimpOperationPointFilter *point = GIMP_OPERATION_POINT_FILTER (operation);
GimpThresholdConfig *config = GIMP_THRESHOLD_CONFIG (point->config);
gfloat *src = in_buf;
gfloat *dest = out_buf;
glong sample;
if (! config)
return FALSE;
for (sample = 0; sample < samples; sample++)
while (samples--)
{
gfloat value;

View File

@ -23,8 +23,7 @@
#define __GIMP_OPERATION_THRESHOLD_H__
#include <gegl-plugin.h>
#include <operation/gegl-operation-point-filter.h>
#include "gimpoperationpointfilter.h"
#define GIMP_TYPE_OPERATION_THRESHOLD (gimp_operation_threshold_get_type ())
@ -39,14 +38,12 @@ typedef struct _GimpOperationThresholdClass GimpOperationThresholdClass;
struct _GimpOperationThreshold
{
GeglOperationPointFilter parent_instance;
GimpThresholdConfig *config;
GimpOperationPointFilter parent_instance;
};
struct _GimpOperationThresholdClass
{
GeglOperationPointFilterClass parent_class;
GimpOperationPointFilterClass parent_class;
};

View File

@ -74,7 +74,7 @@ static guint tile_sink_signals[LAST_SIGNAL] = { 0 };
static void
gimp_operation_tile_sink_class_init (GimpOperationTileSinkClass * klass)
gimp_operation_tile_sink_class_init (GimpOperationTileSinkClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GeglOperationClass *operation_class = GEGL_OPERATION_CLASS (klass);
@ -94,10 +94,11 @@ gimp_operation_tile_sink_class_init (GimpOperationTileSinkClass * klass)
object_class->set_property = gimp_operation_tile_sink_set_property;
object_class->get_property = gimp_operation_tile_sink_get_property;
operation_class->name = "gimp-tilemanager-sink";
sink_class->process = gimp_operation_tile_sink_process;
sink_class->needs_full = FALSE;
gegl_operation_class_set_name (operation_class, "gimp-tilemanager-sink");;
g_object_class_install_property (object_class, PROP_TILE_MANAGER,
g_param_spec_boxed ("tile-manager",
@ -191,14 +192,16 @@ gimp_operation_tile_sink_process (GeglOperation *operation,
const GeglRectangle *result)
{
GimpOperationTileSink *self = GIMP_OPERATION_TILE_SINK (operation);
if (self->tile_manager)
{
const Babl *format;
PixelRegion destPR;
guint bpp = tile_manager_bpp (self->tile_manager);
guint bpp;
gpointer pr;
if (! self->tile_manager)
return FALSE;
bpp = tile_manager_bpp (self->tile_manager);
if (self->linear)
format = gimp_bpp_to_babl_format_linear (bpp);
else
@ -221,11 +224,6 @@ gimp_operation_tile_sink_process (GeglOperation *operation,
g_signal_emit (operation, tile_sink_signals[DATA_WRITTEN], 0,
result);
}
else
{
g_warning ("no tilemanager?");
}
return TRUE;
}

View File

@ -69,7 +69,7 @@ G_DEFINE_TYPE (GimpOperationTileSource, gimp_operation_tile_source,
static void
gimp_operation_tile_source_class_init (GimpOperationTileSourceClass * klass)
gimp_operation_tile_source_class_init (GimpOperationTileSourceClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GeglOperationClass *operation_class = GEGL_OPERATION_CLASS (klass);
@ -79,6 +79,7 @@ gimp_operation_tile_source_class_init (GimpOperationTileSourceClass * klass)
object_class->set_property = gimp_operation_tile_source_set_property;
object_class->get_property = gimp_operation_tile_source_get_property;
operation_class->name = "gimp-tilemanager-source";
operation_class->prepare = gimp_operation_tile_source_prepare;
operation_class->get_defined_region = gimp_operation_tile_source_get_defined_region;
operation_class->adjust_result_region = NULL; /* the default source is
@ -89,7 +90,6 @@ gimp_operation_tile_source_class_init (GimpOperationTileSourceClass * klass)
source_class->process = gimp_operation_tile_source_process;
gegl_operation_class_set_name (operation_class, "gimp-tilemanager-source");;
g_object_class_install_property (object_class, PROP_TILE_MANAGER,
g_param_spec_boxed ("tile-manager",
@ -220,13 +220,13 @@ gimp_operation_tile_source_process (GeglOperation *operation,
const GeglRectangle *result)
{
GimpOperationTileSource *self = GIMP_OPERATION_TILE_SOURCE (operation);
if (self->tile_manager)
{
const Babl *format;
PixelRegion srcPR;
gpointer pr;
if (! self->tile_manager)
return FALSE;
format = gegl_operation_get_format (operation, "output");
pixel_region_init (&srcPR, self->tile_manager,
@ -242,7 +242,6 @@ gimp_operation_tile_source_process (GeglOperation *operation,
gegl_buffer_set (output, &rect, format, srcPR.data, srcPR.rowstride);
}
}
return TRUE;
}

View File

@ -0,0 +1,117 @@
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimpposterizeconfig.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 "libgimpconfig/gimpconfig.h"
#include "gegl-types.h"
#include "gimpposterizeconfig.h"
enum
{
PROP_0,
PROP_LEVELS
};
static void gimp_posterize_config_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec);
static void gimp_posterize_config_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec);
G_DEFINE_TYPE_WITH_CODE (GimpPosterizeConfig, gimp_posterize_config,
G_TYPE_OBJECT,
G_IMPLEMENT_INTERFACE (GIMP_TYPE_CONFIG, NULL))
#define parent_class gimp_posterize_config_parent_class
static void
gimp_posterize_config_class_init (GimpPosterizeConfigClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->set_property = gimp_posterize_config_set_property;
object_class->get_property = gimp_posterize_config_get_property;
g_object_class_install_property (object_class, PROP_LEVELS,
g_param_spec_int ("levels",
"Levels",
"Posterize levels",
2, 256, 3,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT));
}
static void
gimp_posterize_config_init (GimpPosterizeConfig *self)
{
}
static void
gimp_posterize_config_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
{
GimpPosterizeConfig *self = GIMP_POSTERIZE_CONFIG (object);
switch (property_id)
{
case PROP_LEVELS:
g_value_set_int (value, self->levels);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
gimp_posterize_config_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
GimpPosterizeConfig *self = GIMP_POSTERIZE_CONFIG (object);
switch (property_id)
{
case PROP_LEVELS:
self->levels = g_value_get_int (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}

View File

@ -0,0 +1,52 @@
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimpposterizeconfig.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_POSTERIZE_CONFIG_H__
#define __GIMP_POSTERIZE_CONFIG_H__
#define GIMP_TYPE_POSTERIZE_CONFIG (gimp_posterize_config_get_type ())
#define GIMP_POSTERIZE_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_POSTERIZE_CONFIG, GimpPosterizeConfig))
#define GIMP_POSTERIZE_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_POSTERIZE_CONFIG, GimpPosterizeConfigClass))
#define GIMP_IS_POSTERIZE_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_POSTERIZE_CONFIG))
#define GIMP_IS_POSTERIZE_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_POSTERIZE_CONFIG))
#define GIMP_POSTERIZE_CONFIG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_POSTERIZE_CONFIG, GimpPosterizeConfigClass))
typedef struct _GimpPosterizeConfigClass GimpPosterizeConfigClass;
struct _GimpPosterizeConfig
{
GObject parent_instance;
gint levels;
};
struct _GimpPosterizeConfigClass
{
GObjectClass parent_class;
};
GType gimp_posterize_config_get_type (void) G_GNUC_CONST;
#endif /* __GIMP_POSTERIZE_CONFIG_H__ */

View File

@ -23,6 +23,8 @@
#include <gegl.h>
#include "libgimpconfig/gimpconfig.h"
#include "gegl-types.h"
/* temp cruft */
@ -49,14 +51,15 @@ static void gimp_threshold_config_set_property (GObject *object,
GParamSpec *pspec);
G_DEFINE_TYPE (GimpThresholdConfig, gimp_threshold_config,
G_TYPE_OBJECT)
G_DEFINE_TYPE_WITH_CODE (GimpThresholdConfig, gimp_threshold_config,
G_TYPE_OBJECT,
G_IMPLEMENT_INTERFACE (GIMP_TYPE_CONFIG, NULL))
#define parent_class gimp_threshold_config_parent_class
static void
gimp_threshold_config_class_init (GimpThresholdConfigClass * klass)
gimp_threshold_config_class_init (GimpThresholdConfigClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
@ -134,18 +137,6 @@ gimp_threshold_config_set_property (GObject *object,
}
/* public functions */
void
gimp_threshold_config_reset (GimpThresholdConfig *config)
{
g_return_if_fail (GIMP_IS_THRESHOLD_CONFIG (config));
config->low = 0.5;
config->high = 1.0;
}
/* temp cruft */
void

View File

@ -49,8 +49,6 @@ struct _GimpThresholdConfigClass
GType gimp_threshold_config_get_type (void) G_GNUC_CONST;
void gimp_threshold_config_reset (GimpThresholdConfig *config);
/* temp cruft */
void gimp_threshold_config_to_cruft (GimpThresholdConfig *config,
Threshold *cruft);

View File

@ -118,6 +118,8 @@ libapptools_a_sources = \
gimpperspectiveclonetool.h \
gimpperspectivetool.c \
gimpperspectivetool.h \
gimppolygonselecttool.c \
gimppolygonselecttool.h \
gimpposterizetool.c \
gimpposterizetool.h \
gimprectangleselecttool.c \

View File

@ -69,6 +69,7 @@
#include "gimppenciltool.h"
#include "gimpperspectiveclonetool.h"
#include "gimpperspectivetool.h"
#include "gimppolygonselecttool.h"
#include "gimpposterizetool.h"
#include "gimpthresholdtool.h"
#include "gimprectangleselecttool.h"
@ -167,6 +168,7 @@ gimp_tools_init (Gimp *gimp)
gimp_iscissors_tool_register,
gimp_by_color_select_tool_register,
gimp_fuzzy_select_tool_register,
gimp_polygon_select_tool_register,
gimp_free_select_tool_register,
gimp_ellipse_select_tool_register,
gimp_rect_select_tool_register

View File

@ -18,9 +18,12 @@
#include "config.h"
#include <string.h>
#include <gegl.h>
#include <gtk/gtk.h>
#include "libgimpconfig/gimpconfig.h"
#include "libgimpwidgets/gimpwidgets.h"
#include "tools-types.h"
@ -28,6 +31,8 @@
#include "base/gimplut.h"
#include "base/lut-funcs.h"
#include "gegl/gimpbrightnesscontrastconfig.h"
#include "core/gimpdrawable.h"
#include "core/gimpimage.h"
@ -69,12 +74,15 @@ static void gimp_brightness_contrast_tool_motion (GimpTool
GimpDisplay *display);
static GeglNode *
gimp_brightness_contrast_tool_get_operation (GimpImageMapTool *image_map_tool);
gimp_brightness_contrast_tool_get_operation (GimpImageMapTool *image_map_tool,
GObject **config);
static void gimp_brightness_contrast_tool_map (GimpImageMapTool *image_map_tool);
static void gimp_brightness_contrast_tool_dialog (GimpImageMapTool *image_map_tool);
static void gimp_brightness_contrast_tool_reset (GimpImageMapTool *image_map_tool);
static void brightness_contrast_update_sliders (GimpBrightnessContrastTool *bc_tool);
static void brightness_contrast_config_notify (GObject *object,
GParamSpec *pspec,
GimpBrightnessContrastTool *bc_tool);
static void brightness_contrast_brightness_changed (GtkAdjustment *adj,
GimpBrightnessContrastTool *bc_tool);
static void brightness_contrast_contrast_changed (GtkAdjustment *adj,
@ -122,7 +130,6 @@ gimp_brightness_contrast_tool_class_init (GimpBrightnessContrastToolClass *klass
im_tool_class->get_operation = gimp_brightness_contrast_tool_get_operation;
im_tool_class->map = gimp_brightness_contrast_tool_map;
im_tool_class->dialog = gimp_brightness_contrast_tool_dialog;
im_tool_class->reset = gimp_brightness_contrast_tool_reset;
}
static void
@ -130,8 +137,6 @@ gimp_brightness_contrast_tool_init (GimpBrightnessContrastTool *bc_tool)
{
GimpImageMapTool *im_tool = GIMP_IMAGE_MAP_TOOL (bc_tool);
bc_tool->brightness = 0.0;
bc_tool->contrast = 0.0;
bc_tool->lut = gimp_lut_new ();
im_tool->apply_func = (GimpImageMapApplyFunc) gimp_lut_process;
@ -172,19 +177,27 @@ gimp_brightness_contrast_tool_initialize (GimpTool *tool,
return FALSE;
}
bc_tool->brightness = 0.0;
bc_tool->contrast = 0.0;
gimp_config_reset (GIMP_CONFIG (bc_tool->config));
GIMP_TOOL_CLASS (parent_class)->initialize (tool, display, error);
brightness_contrast_update_sliders (bc_tool);
return TRUE;
}
static GeglNode *
gimp_brightness_contrast_tool_get_operation (GimpImageMapTool *im_tool)
gimp_brightness_contrast_tool_get_operation (GimpImageMapTool *im_tool,
GObject **config)
{
GimpBrightnessContrastTool *bc_tool = GIMP_BRIGHTNESS_CONTRAST_TOOL (im_tool);
bc_tool->config = g_object_new (GIMP_TYPE_BRIGHTNESS_CONTRAST_CONFIG, NULL);
*config = G_OBJECT (bc_tool->config);
g_signal_connect_object (bc_tool->config, "notify",
G_CALLBACK (brightness_contrast_config_notify),
G_OBJECT (bc_tool), 0);
return g_object_new (GEGL_TYPE_NODE,
"operation", "brightness-contrast",
NULL);
@ -194,22 +207,13 @@ static void
gimp_brightness_contrast_tool_map (GimpImageMapTool *im_tool)
{
GimpBrightnessContrastTool *bc_tool = GIMP_BRIGHTNESS_CONTRAST_TOOL (im_tool);
gdouble brightness;
gdouble contrast;
brightness = bc_tool->brightness / 256.0;
contrast = (bc_tool->contrast < 0 ?
(bc_tool->contrast + 127.0) / 127.0 :
bc_tool->contrast * 4.0 / 127.0 + 1);
gegl_node_set (im_tool->operation,
"brightness", brightness,
"contrast", contrast,
NULL);
gimp_brightness_contrast_config_set_node (bc_tool->config,
im_tool->operation);
brightness_contrast_lut_setup (bc_tool->lut,
bc_tool->brightness / 255.0,
bc_tool->contrast / 127.0,
bc_tool->config->brightness / 2.0,
bc_tool->config->contrast,
gimp_drawable_bytes (im_tool->drawable));
}
@ -223,10 +227,10 @@ gimp_brightness_contrast_tool_button_press (GimpTool *tool,
{
GimpBrightnessContrastTool *bc_tool = GIMP_BRIGHTNESS_CONTRAST_TOOL (tool);
bc_tool->x = coords->x - bc_tool->contrast;
bc_tool->y = coords->y + bc_tool->brightness;
bc_tool->dx = bc_tool->contrast;
bc_tool->dy = - bc_tool->brightness;
bc_tool->x = coords->x - bc_tool->config->contrast * 127.0;
bc_tool->y = coords->y + bc_tool->config->brightness * 127.0;
bc_tool->dx = bc_tool->config->contrast * 127.0;
bc_tool->dy = - bc_tool->config->brightness * 127.0;
gimp_tool_control_activate (tool->control);
tool->display = display;
@ -249,7 +253,7 @@ gimp_brightness_contrast_tool_button_release (GimpTool *tool,
return;
if (release_type == GIMP_BUTTON_RELEASE_CANCEL)
gimp_brightness_contrast_tool_reset (im_tool);
gimp_config_reset (GIMP_CONFIG (bc_tool->config));
gimp_image_map_tool_preview (im_tool);
}
@ -262,18 +266,16 @@ gimp_brightness_contrast_tool_motion (GimpTool *tool,
GimpDisplay *display)
{
GimpBrightnessContrastTool *bc_tool = GIMP_BRIGHTNESS_CONTRAST_TOOL (tool);
GimpImageMapTool *im_tool = GIMP_IMAGE_MAP_TOOL (tool);
gimp_tool_control_pause (tool->control);
bc_tool->dx = (coords->x - bc_tool->x);
bc_tool->dy = - (coords->y - bc_tool->y);
bc_tool->brightness = CLAMP (bc_tool->dy, -127.0, 127.0);
bc_tool->contrast = CLAMP (bc_tool->dx, -127.0, 127.0);
brightness_contrast_update_sliders (bc_tool);
gimp_image_map_tool_preview (im_tool);
g_object_set (bc_tool->config,
"brightness", CLAMP (bc_tool->dy, -127.0, 127.0) / 127.0,
"contrast", CLAMP (bc_tool->dx, -127.0, 127.0) / 127.0,
NULL);
gimp_tool_control_resume (tool->control);
}
@ -287,6 +289,7 @@ static void
gimp_brightness_contrast_tool_dialog (GimpImageMapTool *im_tool)
{
GimpBrightnessContrastTool *bc_tool = GIMP_BRIGHTNESS_CONTRAST_TOOL (im_tool);
GimpBrightnessContrastConfig *config = bc_tool->config;
GtkWidget *table;
GtkWidget *slider;
GtkObject *data;
@ -302,7 +305,7 @@ gimp_brightness_contrast_tool_dialog (GimpImageMapTool *im_tool)
/* Create the brightness scale widget */
data = gimp_scale_entry_new (GTK_TABLE (table), 0, 0,
_("_Brightness:"), SLIDER_WIDTH, -1,
bc_tool->brightness,
config->brightness * 127.0,
-127.0, 127.0, 1.0, 10.0, 0,
TRUE, 0.0, 0.0,
NULL, NULL);
@ -317,7 +320,7 @@ gimp_brightness_contrast_tool_dialog (GimpImageMapTool *im_tool)
/* Create the contrast scale widget */
data = gimp_scale_entry_new (GTK_TABLE (table), 0, 1,
_("Con_trast:"), SLIDER_WIDTH, -1,
bc_tool->contrast,
config->contrast * 127.0,
-127.0, 127.0, 1.0, 10.0, 0,
TRUE, 0.0, 0.0,
NULL, NULL);
@ -331,32 +334,41 @@ gimp_brightness_contrast_tool_dialog (GimpImageMapTool *im_tool)
}
static void
gimp_brightness_contrast_tool_reset (GimpImageMapTool *im_tool)
brightness_contrast_config_notify (GObject *object,
GParamSpec *pspec,
GimpBrightnessContrastTool *bc_tool)
{
GimpBrightnessContrastTool *bc_tool = GIMP_BRIGHTNESS_CONTRAST_TOOL (im_tool);
GimpBrightnessContrastConfig *config = GIMP_BRIGHTNESS_CONTRAST_CONFIG (object);
bc_tool->brightness = 0.0;
bc_tool->contrast = 0.0;
if (! bc_tool->brightness_data)
return;
brightness_contrast_update_sliders (bc_tool);
}
if (! strcmp (pspec->name, "brightness"))
{
gtk_adjustment_set_value (bc_tool->brightness_data,
config->brightness * 127.0);
}
else if (! strcmp (pspec->name, "contrast"))
{
gtk_adjustment_set_value (bc_tool->contrast_data,
config->contrast * 127.0);
}
static void
brightness_contrast_update_sliders (GimpBrightnessContrastTool *bc_tool)
{
gtk_adjustment_set_value (bc_tool->brightness_data, bc_tool->brightness);
gtk_adjustment_set_value (bc_tool->contrast_data, bc_tool->contrast);
gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (bc_tool));
}
static void
brightness_contrast_brightness_changed (GtkAdjustment *adjustment,
GimpBrightnessContrastTool *bc_tool)
{
if (bc_tool->brightness != adjustment->value)
{
bc_tool->brightness = adjustment->value;
GimpBrightnessContrastConfig *config = bc_tool->config;
gdouble value = adjustment->value / 127.0;
gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (bc_tool));
if (config->brightness != value)
{
g_object_set (config,
"brightness", value,
NULL);
}
}
@ -364,10 +376,13 @@ static void
brightness_contrast_contrast_changed (GtkAdjustment *adjustment,
GimpBrightnessContrastTool *bc_tool)
{
if (bc_tool->contrast != adjustment->value)
{
bc_tool->contrast = adjustment->value;
GimpBrightnessContrastConfig *config = bc_tool->config;
gdouble value = adjustment->value / 127.0;
gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (bc_tool));
if (config->contrast != value)
{
g_object_set (config,
"contrast", value,
NULL);
}
}

View File

@ -38,13 +38,12 @@ struct _GimpBrightnessContrastTool
{
GimpImageMapTool parent_instance;
GimpBrightnessContrastConfig *config;
GimpLut *lut;
gdouble x, y;
gdouble dx, dy;
gdouble brightness;
gdouble contrast;
GimpLut *lut;
/* dialog */
GtkAdjustment *brightness_data;
GtkAdjustment *contrast_data;

View File

@ -18,9 +18,12 @@
#include "config.h"
#include <string.h>
#include <gegl.h>
#include <gtk/gtk.h>
#include "libgimpconfig/gimpconfig.h"
#include "libgimpwidgets/gimpwidgets.h"
#include "tools-types.h"
@ -50,12 +53,16 @@ static gboolean gimp_color_balance_tool_initialize (GimpTool *tool,
GimpDisplay *display,
GError **error);
static GeglNode * gimp_color_balance_tool_get_operation (GimpImageMapTool *im_tool);
static GeglNode * gimp_color_balance_tool_get_operation (GimpImageMapTool *im_tool,
GObject **config);
static void gimp_color_balance_tool_map (GimpImageMapTool *im_tool);
static void gimp_color_balance_tool_dialog (GimpImageMapTool *im_tool);
static void gimp_color_balance_tool_reset (GimpImageMapTool *im_tool);
static void color_balance_update (GimpColorBalanceTool *cb_tool);
static void color_balance_config_notify (GObject *object,
GParamSpec *pspec,
GimpColorBalanceTool *cb_tool);
static void color_balance_range_callback (GtkWidget *widget,
GimpColorBalanceTool *cb_tool);
static void color_balance_range_reset_callback (GtkWidget *widget,
@ -129,12 +136,6 @@ 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);
@ -160,20 +161,16 @@ gimp_color_balance_tool_initialize (GimpTool *tool,
return FALSE;
}
gimp_color_balance_config_reset (cb_tool->config);
gimp_config_reset (GIMP_CONFIG (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;
}
static GeglNode *
gimp_color_balance_tool_get_operation (GimpImageMapTool *im_tool)
gimp_color_balance_tool_get_operation (GimpImageMapTool *im_tool,
GObject **config)
{
GimpColorBalanceTool *cb_tool = GIMP_COLOR_BALANCE_TOOL (im_tool);
GeglNode *node;
@ -184,6 +181,12 @@ gimp_color_balance_tool_get_operation (GimpImageMapTool *im_tool)
cb_tool->config = g_object_new (GIMP_TYPE_COLOR_BALANCE_CONFIG, NULL);
*config = G_OBJECT (cb_tool->config);
g_signal_connect_object (cb_tool->config, "notify",
G_CALLBACK (color_balance_config_notify),
G_OBJECT (cb_tool), 0);
gegl_node_set (node,
"config", cb_tool->config,
NULL);
@ -205,7 +208,8 @@ gimp_color_balance_tool_map (GimpImageMapTool *image_map_tool)
/**************************/
static GtkAdjustment *
create_levels_scale (const gchar *left,
create_levels_scale (gdouble value,
const gchar *left,
const gchar *right,
GtkWidget *table,
gint col)
@ -222,7 +226,8 @@ create_levels_scale (const gchar *left,
gtk_widget_show (label);
spinbutton = gimp_spin_button_new (&adj,
0, -100.0, 100.0, 1.0, 10.0, 0.0, 1.0, 0);
value, -100.0, 100.0,
1.0, 10.0, 0.0, 1.0, 0);
slider = gtk_hscale_new (GTK_ADJUSTMENT (adj));
gtk_scale_set_draw_value (GTK_SCALE (slider), FALSE);
@ -248,6 +253,7 @@ static void
gimp_color_balance_tool_dialog (GimpImageMapTool *im_tool)
{
GimpColorBalanceTool *cb_tool = GIMP_COLOR_BALANCE_TOOL (im_tool);
GimpColorBalanceConfig *config = cb_tool->config;
GtkWidget *vbox;
GtkWidget *hbox;
GtkWidget *table;
@ -259,6 +265,8 @@ gimp_color_balance_tool_dialog (GimpImageMapTool *im_tool)
G_CALLBACK (color_balance_range_callback),
cb_tool,
&cb_tool->range_radio);
gimp_int_radio_group_set_active (GTK_RADIO_BUTTON (cb_tool->range_radio),
config->range);
gtk_box_pack_start (GTK_BOX (im_tool->main_vbox), frame, FALSE, FALSE, 0);
gtk_widget_show (frame);
@ -277,21 +285,27 @@ 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"),
cb_tool->cyan_red_adj =
create_levels_scale (config->cyan_red[config->range] * 100.0,
_("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"),
cb_tool->magenta_green_adj =
create_levels_scale (config->magenta_green[config->range] * 100.0,
_("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"),
cb_tool->yellow_blue_adj =
create_levels_scale (config->yellow_blue[config->range] * 100.0,
_("Yellow"), _("Blue"),
table, 2);
g_signal_connect (cb_tool->yellow_blue_adj, "value-changed",
@ -313,7 +327,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->config->preserve_luminosity);
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);
@ -329,28 +343,53 @@ 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_freeze_notify (G_OBJECT (cb_tool->config));
gimp_config_reset (GIMP_CONFIG (cb_tool->config));
g_object_set (cb_tool->config,
"range", range,
NULL);
color_balance_update (cb_tool);
g_object_thaw_notify (G_OBJECT (cb_tool->config));
}
static void
color_balance_update (GimpColorBalanceTool *cb_tool)
color_balance_config_notify (GObject *object,
GParamSpec *pspec,
GimpColorBalanceTool *cb_tool)
{
GimpColorBalanceConfig *config = cb_tool->config;
GimpColorBalanceConfig *config = GIMP_COLOR_BALANCE_CONFIG (object);
if (! cb_tool->cyan_red_adj)
return;
if (! strcmp (pspec->name, "range"))
{
gimp_int_radio_group_set_active (GTK_RADIO_BUTTON (cb_tool->range_radio),
config->range);
}
else if (! strcmp (pspec->name, "cyan-red"))
{
gtk_adjustment_set_value (cb_tool->cyan_red_adj,
config->cyan_red[config->range] * 100.0);
}
else if (! strcmp (pspec->name, "magenta-green"))
{
gtk_adjustment_set_value (cb_tool->magenta_green_adj,
config->magenta_green[config->range] * 100.0);
}
else if (! strcmp (pspec->name, "yellow-blue"))
{
gtk_adjustment_set_value (cb_tool->yellow_blue_adj,
config->yellow_blue[config->range] * 100.0);
}
else if (! strcmp (pspec->name, "preserve-luminosity"))
{
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (cb_tool->preserve_toggle),
config->preserve_luminosity);
}
gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (cb_tool));
}
static void
@ -365,8 +404,6 @@ color_balance_range_callback (GtkWidget *widget,
g_object_set (cb_tool->config,
"range", range,
NULL);
color_balance_update (cb_tool);
}
}
@ -374,12 +411,7 @@ static void
color_balance_range_reset_callback (GtkWidget *widget,
GimpColorBalanceTool *cb_tool)
{
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));
gimp_color_balance_config_reset_range (cb_tool->config);
}
static void
@ -394,8 +426,6 @@ color_balance_preserve_toggled (GtkWidget *widget,
g_object_set (config,
"preserve-luminosity", active,
NULL);
gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (cb_tool));
}
}
@ -411,8 +441,6 @@ color_balance_cr_changed (GtkAdjustment *adjustment,
g_object_set (config,
"cyan-red", value,
NULL);
gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (cb_tool));
}
}
@ -428,8 +456,6 @@ color_balance_mg_changed (GtkAdjustment *adjustment,
g_object_set (config,
"magenta-green", value,
NULL);
gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (cb_tool));
}
}
@ -445,7 +471,5 @@ color_balance_yb_changed (GtkAdjustment *adjustment,
g_object_set (config,
"yellow-blue", value,
NULL);
gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (cb_tool));
}
}

View File

@ -18,9 +18,12 @@
#include "config.h"
#include <string.h>
#include <gegl.h>
#include <gtk/gtk.h>
#include "libgimpconfig/gimpconfig.h"
#include "libgimpwidgets/gimpwidgets.h"
#include "tools-types.h"
@ -53,12 +56,15 @@ static gboolean gimp_colorize_tool_initialize (GimpTool *tool,
GimpDisplay *display,
GError **error);
static GeglNode * gimp_colorize_tool_get_operation (GimpImageMapTool *im_tool);
static GeglNode * gimp_colorize_tool_get_operation (GimpImageMapTool *im_tool,
GObject **config);
static void gimp_colorize_tool_map (GimpImageMapTool *im_tool);
static void gimp_colorize_tool_dialog (GimpImageMapTool *im_tool);
static void gimp_colorize_tool_reset (GimpImageMapTool *im_tool);
static void colorize_update_sliders (GimpColorizeTool *col_tool);
static void gimp_colorize_tool_config_notify (GObject *object,
GParamSpec *pspec,
GimpColorizeTool *col_tool);
static void colorize_hue_changed (GtkAdjustment *adj,
GimpColorizeTool *col_tool);
static void colorize_saturation_changed (GtkAdjustment *adj,
@ -104,7 +110,6 @@ gimp_colorize_tool_class_init (GimpColorizeToolClass *klass)
im_tool_class->get_operation = gimp_colorize_tool_get_operation;
im_tool_class->map = gimp_colorize_tool_map;
im_tool_class->dialog = gimp_colorize_tool_dialog;
im_tool_class->reset = gimp_colorize_tool_reset;
}
static void
@ -125,12 +130,6 @@ gimp_colorize_tool_finalize (GObject *object)
{
GimpColorizeTool *col_tool = GIMP_COLORIZE_TOOL (object);
if (col_tool->config)
{
g_object_unref (col_tool->config);
col_tool->config = NULL;
}
g_slice_free (Colorize, col_tool->colorize);
G_OBJECT_CLASS (parent_class)->finalize (object);
@ -154,31 +153,36 @@ gimp_colorize_tool_initialize (GimpTool *tool,
return FALSE;
}
gimp_colorize_config_reset (col_tool->config);
gimp_config_reset (GIMP_CONFIG (col_tool->config));
GIMP_TOOL_CLASS (parent_class)->initialize (tool, display, error);
colorize_update_sliders (col_tool);
gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (tool));
return TRUE;
}
static GeglNode *
gimp_colorize_tool_get_operation (GimpImageMapTool *im_tool)
gimp_colorize_tool_get_operation (GimpImageMapTool *im_tool,
GObject **config)
{
GimpColorizeTool *tool = GIMP_COLORIZE_TOOL (im_tool);
GimpColorizeTool *col_tool = GIMP_COLORIZE_TOOL (im_tool);
GeglNode *node;
node = g_object_new (GEGL_TYPE_NODE,
"operation", "gimp-colorize",
NULL);
tool->config = g_object_new (GIMP_TYPE_COLORIZE_CONFIG, NULL);
col_tool->config = g_object_new (GIMP_TYPE_COLORIZE_CONFIG, NULL);
*config = G_OBJECT (col_tool->config);
g_signal_connect_object (col_tool->config, "notify",
G_CALLBACK (gimp_colorize_tool_config_notify),
G_OBJECT (col_tool), 0);
gegl_node_set (node,
"config", tool->config,
"config", col_tool->config,
NULL);
return node;
@ -226,7 +230,8 @@ gimp_colorize_tool_dialog (GimpImageMapTool *image_map_tool)
/* Create the hue scale widget */
data = gimp_scale_entry_new (GTK_TABLE (table), 0, 0,
_("_Hue:"), SLIDER_WIDTH, -1,
0.0, 0.0, 360.0, 1.0, 15.0, 0,
col_tool->config->hue * 360.0,
0.0, 360.0, 1.0, 15.0, 0,
TRUE, 0.0, 0.0,
NULL, NULL);
col_tool->hue_data = GTK_ADJUSTMENT (data);
@ -240,7 +245,8 @@ gimp_colorize_tool_dialog (GimpImageMapTool *image_map_tool)
/* Create the saturation scale widget */
data = gimp_scale_entry_new (GTK_TABLE (table), 0, 1,
_("_Saturation:"), SLIDER_WIDTH, -1,
0.0, 0.0, 100.0, 1.0, 10.0, 0,
col_tool->config->saturation * 100.0,
0.0, 100.0, 1.0, 10.0, 0,
TRUE, 0.0, 0.0,
NULL, NULL);
col_tool->saturation_data = GTK_ADJUSTMENT (data);
@ -254,7 +260,8 @@ gimp_colorize_tool_dialog (GimpImageMapTool *image_map_tool)
/* Create the lightness scale widget */
data = gimp_scale_entry_new (GTK_TABLE (table), 0, 2,
_("_Lightness:"), SLIDER_WIDTH, -1,
0.0, -100.0, 100.0, 1.0, 10.0, 0,
col_tool->config->lightness * 100.0,
-100.0, 100.0, 1.0, 10.0, 0,
TRUE, 0.0, 0.0,
NULL, NULL);
col_tool->lightness_data = GTK_ADJUSTMENT (data);
@ -267,24 +274,32 @@ gimp_colorize_tool_dialog (GimpImageMapTool *image_map_tool)
}
static void
gimp_colorize_tool_reset (GimpImageMapTool *image_map_tool)
gimp_colorize_tool_config_notify (GObject *object,
GParamSpec *pspec,
GimpColorizeTool *col_tool)
{
GimpColorizeTool *col_tool = GIMP_COLORIZE_TOOL (image_map_tool);
GimpColorizeConfig *config = GIMP_COLORIZE_CONFIG (object);
gimp_colorize_config_reset (col_tool->config);
if (! col_tool->hue_data)
return;
colorize_update_sliders (col_tool);
}
static void
colorize_update_sliders (GimpColorizeTool *col_tool)
{
if (! strcmp (pspec->name, "hue"))
{
gtk_adjustment_set_value (col_tool->hue_data,
col_tool->config->hue * 360.0);
config->hue * 360.0);
}
else if (! strcmp (pspec->name, "saturation"))
{
gtk_adjustment_set_value (col_tool->saturation_data,
col_tool->config->saturation * 100.0);
config->saturation * 100.0);
}
else if (! strcmp (pspec->name, "lightness"))
{
gtk_adjustment_set_value (col_tool->lightness_data,
col_tool->config->lightness * 100.0);
config->lightness * 100.0);
}
gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (col_tool));
}
static void
@ -298,8 +313,6 @@ colorize_hue_changed (GtkAdjustment *adjustment,
g_object_set (col_tool->config,
"hue", value,
NULL);
gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (col_tool));
}
}
@ -314,8 +327,6 @@ colorize_saturation_changed (GtkAdjustment *adjustment,
g_object_set (col_tool->config,
"saturation", value,
NULL);
gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (col_tool));
}
}
@ -330,7 +341,5 @@ colorize_lightness_changed (GtkAdjustment *adjustment,
g_object_set (col_tool->config,
"lightness", value,
NULL);
gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (col_tool));
}
}

View File

@ -22,6 +22,7 @@
#include <gtk/gtk.h>
#include "libgimpcolor/gimpcolor.h"
#include "libgimpconfig/gimpconfig.h"
#include "libgimpwidgets/gimpwidgets.h"
#include "tools-types.h"
@ -83,7 +84,8 @@ static void gimp_curves_tool_color_picked (GimpColorTool *color_t
GimpImageType sample_type,
GimpRGB *color,
gint color_index);
static GeglNode * gimp_curves_tool_get_operation (GimpImageMapTool *image_map_tool);
static GeglNode * gimp_curves_tool_get_operation (GimpImageMapTool *image_map_tool,
GObject **config);
static void gimp_curves_tool_map (GimpImageMapTool *image_map_tool);
static void gimp_curves_tool_dialog (GimpImageMapTool *image_map_tool);
static void gimp_curves_tool_reset (GimpImageMapTool *image_map_tool);
@ -93,8 +95,10 @@ static gboolean gimp_curves_tool_settings_load (GimpImageMapTool *image_m
static gboolean gimp_curves_tool_settings_save (GimpImageMapTool *image_map_tool,
gpointer fp);
static void curves_curve_callback (GimpCurve *curve,
static void gimp_curves_tool_config_notify (GObject *object,
GParamSpec *pspec,
GimpCurvesTool *tool);
static void curves_channel_callback (GtkWidget *widget,
GimpCurvesTool *tool);
static void curves_channel_reset_callback (GtkWidget *widget,
@ -186,12 +190,6 @@ gimp_curves_tool_finalize (GObject *object)
{
GimpCurvesTool *tool = GIMP_CURVES_TOOL (object);
if (tool->config)
{
g_object_unref (tool->config);
tool->config = NULL;
}
gimp_lut_free (tool->lut);
if (tool->hist)
@ -210,7 +208,6 @@ gimp_curves_tool_initialize (GimpTool *tool,
{
GimpCurvesTool *c_tool = GIMP_CURVES_TOOL (tool);
GimpDrawable *drawable = gimp_image_get_active_drawable (display->image);
gint i;
if (! drawable)
return FALSE;
@ -222,8 +219,7 @@ gimp_curves_tool_initialize (GimpTool *tool,
return FALSE;
}
for (i = 0; i < G_N_ELEMENTS (c_tool->config->curve); i++)
gimp_curve_reset (c_tool->config->curve[i], TRUE);
gimp_config_reset (GIMP_CONFIG (c_tool->config));
if (! c_tool->hist)
c_tool->hist = gimp_histogram_new ();
@ -382,11 +378,11 @@ gimp_curves_tool_color_picked (GimpColorTool *color_tool,
}
static GeglNode *
gimp_curves_tool_get_operation (GimpImageMapTool *image_map_tool)
gimp_curves_tool_get_operation (GimpImageMapTool *image_map_tool,
GObject **config)
{
GimpCurvesTool *tool = GIMP_CURVES_TOOL (image_map_tool);
GeglNode *node;
gint i;
node = g_object_new (GEGL_TYPE_NODE,
"operation", "gimp-curves",
@ -394,12 +390,11 @@ gimp_curves_tool_get_operation (GimpImageMapTool *image_map_tool)
tool->config = g_object_new (GIMP_TYPE_CURVES_CONFIG, NULL);
for (i = 0; i < G_N_ELEMENTS (tool->config->curve); i++)
{
g_signal_connect_object (tool->config->curve[i], "dirty",
G_CALLBACK (curves_curve_callback),
*config = G_OBJECT (tool->config);
g_signal_connect_object (tool->config, "notify",
G_CALLBACK (gimp_curves_tool_config_notify),
tool, 0);
}
gegl_node_set (node,
"config", tool->config,
@ -606,12 +601,14 @@ static void
gimp_curves_tool_reset (GimpImageMapTool *image_map_tool)
{
GimpCurvesTool *tool = GIMP_CURVES_TOOL (image_map_tool);
GimpHistogramChannel channel = tool->config->channel;
GimpHistogramChannel channel;
gimp_curves_config_reset (tool->config);
g_object_set (tool->config,
"channel", channel,
NULL);
for (channel = GIMP_HISTOGRAM_VALUE;
channel <= GIMP_HISTOGRAM_ALPHA;
channel++)
{
gimp_curve_reset (tool->config->curve[channel], FALSE);
}
}
static gboolean
@ -621,15 +618,7 @@ gimp_curves_tool_settings_load (GimpImageMapTool *image_map_tool,
{
GimpCurvesTool *tool = GIMP_CURVES_TOOL (image_map_tool);
if (gimp_curves_config_load_cruft (tool->config, fp, error))
{
gimp_int_radio_group_set_active (GTK_RADIO_BUTTON (tool->curve_type),
GIMP_CURVE_SMOOTH);
return TRUE;
}
return FALSE;
return gimp_curves_config_load_cruft (tool->config, fp, error);
}
static gboolean
@ -642,15 +631,16 @@ gimp_curves_tool_settings_save (GimpImageMapTool *image_map_tool,
}
static void
curves_curve_callback (GimpCurve *curve,
gimp_curves_tool_config_notify (GObject *object,
GParamSpec *pspec,
GimpCurvesTool *tool)
{
GimpCurvesConfig *config = tool->config;
GimpCurvesConfig *config = GIMP_CURVES_CONFIG (object);
if (curve != config->curve[config->channel])
if (! tool->xrange)
return;
if (tool->xrange)
if (! strcmp (pspec->name, "channel"))
{
switch (config->channel)
{
@ -672,25 +662,6 @@ curves_curve_callback (GimpCurve *curve,
config->curve[GIMP_HISTOGRAM_BLUE]->curve);
break;
}
}
if (GIMP_IMAGE_MAP_TOOL (tool)->drawable)
gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (tool));
}
static void
curves_channel_callback (GtkWidget *widget,
GimpCurvesTool *tool)
{
gint value;
if (gimp_int_combo_box_get_active (GIMP_INT_COMBO_BOX (widget), &value))
{
GimpCurvesConfig *config = tool->config;
g_object_set (config,
"channel", value,
NULL);
gimp_histogram_view_set_channel (GIMP_HISTOGRAM_VIEW (tool->graph),
config->channel);
@ -702,11 +673,29 @@ curves_channel_callback (GtkWidget *widget,
gimp_curve_view_set_curve (GIMP_CURVE_VIEW (tool->graph),
config->curve[config->channel]);
}
else if (! strcmp (pspec->name, "curve"))
{
gimp_int_radio_group_set_active (GTK_RADIO_BUTTON (tool->curve_type),
config->curve[config->channel]->curve_type);
}
curves_curve_callback (config->curve[config->channel], tool);
gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (tool));
}
static void
curves_channel_callback (GtkWidget *widget,
GimpCurvesTool *tool)
{
GimpCurvesConfig *config = tool->config;
gint value;
if (gimp_int_combo_box_get_active (GIMP_INT_COMBO_BOX (widget), &value) &&
config->channel != value)
{
g_object_set (config,
"channel", value,
NULL);
}
}
@ -714,7 +703,7 @@ static void
curves_channel_reset_callback (GtkWidget *widget,
GimpCurvesTool *tool)
{
gimp_curves_config_reset_channel (tool->config, tool->config->channel);
gimp_curve_reset (tool->config->curve[tool->config->channel], FALSE);
}
static gboolean

View File

@ -18,9 +18,12 @@
#include "config.h"
#include <string.h>
#include <gegl.h>
#include <gtk/gtk.h>
#include "libgimpconfig/gimpconfig.h"
#include "libgimpwidgets/gimpwidgets.h"
#include "tools-types.h"
@ -56,12 +59,16 @@ static gboolean gimp_hue_saturation_tool_initialize (GimpTool *tool
GimpDisplay *display,
GError **error);
static GeglNode * gimp_hue_saturation_tool_get_operation (GimpImageMapTool *im_tool);
static GeglNode * gimp_hue_saturation_tool_get_operation (GimpImageMapTool *im_tool,
GObject **config);
static void gimp_hue_saturation_tool_map (GimpImageMapTool *im_tool);
static void gimp_hue_saturation_tool_dialog (GimpImageMapTool *im_tool);
static void gimp_hue_saturation_tool_reset (GimpImageMapTool *im_tool);
static void hue_saturation_update_sliders (GimpHueSaturationTool *hs_tool);
static void hue_saturation_config_notify (GObject *object,
GParamSpec *pspec,
GimpHueSaturationTool *hs_tool);
static void hue_saturation_update_color_areas (GimpHueSaturationTool *hs_tool);
static void hue_saturation_range_callback (GtkWidget *widget,
@ -137,12 +144,6 @@ gimp_hue_saturation_tool_finalize (GObject *object)
{
GimpHueSaturationTool *hs_tool = GIMP_HUE_SATURATION_TOOL (object);
if (hs_tool->config)
{
g_object_unref (hs_tool->config);
hs_tool->config = NULL;
}
g_slice_free (HueSaturation, hs_tool->hue_saturation);
G_OBJECT_CLASS (parent_class)->finalize (object);
@ -168,21 +169,16 @@ gimp_hue_saturation_tool_initialize (GimpTool *tool,
return FALSE;
}
gimp_hue_saturation_config_reset (hs_tool->config);
gimp_config_reset (GIMP_CONFIG (hs_tool->config));
GIMP_TOOL_CLASS (parent_class)->initialize (tool, display, error);
gimp_int_radio_group_set_active (GTK_RADIO_BUTTON (hs_tool->range_radio),
hs_tool->config->range);
hue_saturation_update_sliders (hs_tool);
hue_saturation_update_color_areas (hs_tool);
return TRUE;
}
static GeglNode *
gimp_hue_saturation_tool_get_operation (GimpImageMapTool *im_tool)
gimp_hue_saturation_tool_get_operation (GimpImageMapTool *im_tool,
GObject **config)
{
GimpHueSaturationTool *hs_tool = GIMP_HUE_SATURATION_TOOL (im_tool);
GeglNode *node;
@ -193,6 +189,12 @@ gimp_hue_saturation_tool_get_operation (GimpImageMapTool *im_tool)
hs_tool->config = g_object_new (GIMP_TYPE_HUE_SATURATION_CONFIG, NULL);
*config = G_OBJECT (hs_tool->config);
g_signal_connect_object (hs_tool->config, "notify",
G_CALLBACK (hue_saturation_config_notify),
G_OBJECT (hs_tool), 0);
gegl_node_set (node,
"config", hs_tool->config,
NULL);
@ -217,6 +219,7 @@ static void
gimp_hue_saturation_tool_dialog (GimpImageMapTool *image_map_tool)
{
GimpHueSaturationTool *hs_tool = GIMP_HUE_SATURATION_TOOL (image_map_tool);
GimpHueSaturationConfig *config = hs_tool->config;
GtkWidget *vbox;
GtkWidget *abox;
GtkWidget *table;
@ -342,7 +345,8 @@ gimp_hue_saturation_tool_dialog (GimpImageMapTool *image_map_tool)
data = gimp_scale_entry_new (GTK_TABLE (table), 0, 0,
_("_Overlap:"), SLIDER_WIDTH, -1,
0.0, 0, 100.0, 1.0, 15.0, 0,
config->overlap * 100.0,
0.0, 100.0, 1.0, 15.0, 0,
TRUE, 0.0, 0.0,
NULL, NULL);
hs_tool->overlap_data = GTK_ADJUSTMENT (data);
@ -378,7 +382,8 @@ gimp_hue_saturation_tool_dialog (GimpImageMapTool *image_map_tool)
/* Create the hue scale widget */
data = gimp_scale_entry_new (GTK_TABLE (table), 0, 0,
_("_Hue:"), SLIDER_WIDTH, -1,
0.0, -180.0, 180.0, 1.0, 15.0, 0,
config->hue[config->range] * 180.0,
-180.0, 180.0, 1.0, 15.0, 0,
TRUE, 0.0, 0.0,
NULL, NULL);
hs_tool->hue_data = GTK_ADJUSTMENT (data);
@ -396,7 +401,8 @@ gimp_hue_saturation_tool_dialog (GimpImageMapTool *image_map_tool)
/* Create the lightness scale widget */
data = gimp_scale_entry_new (GTK_TABLE (table), 0, 1,
_("_Lightness:"), SLIDER_WIDTH, -1,
0.0, -100.0, 100.0, 1.0, 10.0, 0,
config->lightness[config->range] * 100.0,
-100.0, 100.0, 1.0, 10.0, 0,
TRUE, 0.0, 0.0,
NULL, NULL);
hs_tool->lightness_data = GTK_ADJUSTMENT (data);
@ -414,7 +420,8 @@ gimp_hue_saturation_tool_dialog (GimpImageMapTool *image_map_tool)
/* Create the saturation scale widget */
data = gimp_scale_entry_new (GTK_TABLE (table), 0, 2,
_("_Saturation:"), SLIDER_WIDTH, -1,
0.0, -100.0, 100.0, 1.0, 10.0, 0,
config->saturation[config->range] * 100.0,
-100.0, 100.0, 1.0, 10.0, 0,
TRUE, 0.0, 0.0,
NULL, NULL);
hs_tool->saturation_data = GTK_ADJUSTMENT (data);
@ -440,6 +447,11 @@ gimp_hue_saturation_tool_dialog (GimpImageMapTool *image_map_tool)
g_signal_connect (button, "clicked",
G_CALLBACK (hue_saturation_range_reset_callback),
hs_tool);
gimp_int_radio_group_set_active (GTK_RADIO_BUTTON (hs_tool->range_radio),
config->range);
hue_saturation_update_color_areas (hs_tool);
}
static void
@ -448,28 +460,55 @@ gimp_hue_saturation_tool_reset (GimpImageMapTool *image_map_tool)
GimpHueSaturationTool *hs_tool = GIMP_HUE_SATURATION_TOOL (image_map_tool);
GimpHueRange range = hs_tool->config->range;
gimp_hue_saturation_config_reset (hs_tool->config);
g_object_freeze_notify (G_OBJECT (hs_tool->config));
gimp_config_reset (GIMP_CONFIG (hs_tool->config));
g_object_set (hs_tool->config,
"range", range,
NULL);
hue_saturation_update_sliders (hs_tool);
hue_saturation_update_color_areas (hs_tool);
g_object_thaw_notify (G_OBJECT (hs_tool->config));
}
static void
hue_saturation_update_sliders (GimpHueSaturationTool *hs_tool)
hue_saturation_config_notify (GObject *object,
GParamSpec *pspec,
GimpHueSaturationTool *hs_tool)
{
GimpHueSaturationConfig *config = hs_tool->config;
GimpHueSaturationConfig *config = GIMP_HUE_SATURATION_CONFIG (object);
if (! hs_tool->hue_data)
return;
if (! strcmp (pspec->name, "range"))
{
gimp_int_radio_group_set_active (GTK_RADIO_BUTTON (hs_tool->range_radio),
config->range);
}
else if (! strcmp (pspec->name, "hue"))
{
gtk_adjustment_set_value (hs_tool->hue_data,
config->hue[config->range] * 180.0);
}
else if (! strcmp (pspec->name, "lightness"))
{
gtk_adjustment_set_value (hs_tool->lightness_data,
config->lightness[config->range] * 100.0);
}
else if (! strcmp (pspec->name, "saturation"))
{
gtk_adjustment_set_value (hs_tool->saturation_data,
config->saturation[config->range] * 100.0);
}
else if (! strcmp (pspec->name, "overlap"))
{
gtk_adjustment_set_value (hs_tool->overlap_data,
config->overlap * 100.0);
}
hue_saturation_update_color_areas (hs_tool);
gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (hs_tool));
}
static void
@ -511,8 +550,6 @@ hue_saturation_range_callback (GtkWidget *widget,
g_object_set (hs_tool->config,
"range", range,
NULL);
hue_saturation_update_sliders (hs_tool);
}
}
@ -520,13 +557,7 @@ static void
hue_saturation_range_reset_callback (GtkWidget *widget,
GimpHueSaturationTool *hs_tool)
{
gimp_hue_saturation_config_reset_range (hs_tool->config,
hs_tool->config->range);
hue_saturation_update_sliders (hs_tool);
hue_saturation_update_color_areas (hs_tool);
gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (hs_tool));
gimp_hue_saturation_config_reset_range (hs_tool->config);
}
static void
@ -541,10 +572,6 @@ hue_saturation_hue_changed (GtkAdjustment *adjustment,
g_object_set (config,
"hue", value,
NULL);
hue_saturation_update_color_areas (hs_tool);
gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (hs_tool));
}
}
@ -560,10 +587,6 @@ hue_saturation_lightness_changed (GtkAdjustment *adjustment,
g_object_set (config,
"lightness", value,
NULL);
hue_saturation_update_color_areas (hs_tool);
gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (hs_tool));
}
}
@ -579,10 +602,6 @@ hue_saturation_saturation_changed (GtkAdjustment *adjustment,
g_object_set (config,
"saturation", value,
NULL);
hue_saturation_update_color_areas (hs_tool);
gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (hs_tool));
}
}
@ -598,9 +617,5 @@ hue_saturation_overlap_changed (GtkAdjustment *adjustment,
g_object_set (config,
"overlap", value,
NULL);
hue_saturation_update_color_areas (hs_tool);
gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (hs_tool));
}
}

View File

@ -26,6 +26,7 @@
#include <gdk/gdkkeysyms.h>
#include "libgimpbase/gimpbase.h"
#include "libgimpconfig/gimpconfig.h"
#include "libgimpwidgets/gimpwidgets.h"
#include "tools-types.h"
@ -163,6 +164,7 @@ gimp_image_map_tool_init (GimpImageMapTool *image_map_tool)
image_map_tool->drawable = NULL;
image_map_tool->operation = NULL;
image_map_tool->config = NULL;
image_map_tool->image_map = NULL;
image_map_tool->shell = NULL;
@ -187,7 +189,8 @@ gimp_image_map_tool_constructor (GType type,
klass = GIMP_IMAGE_MAP_TOOL_GET_CLASS (image_map_tool);
if (klass->get_operation)
image_map_tool->operation = klass->get_operation (image_map_tool);
image_map_tool->operation = klass->get_operation (image_map_tool,
&image_map_tool->config);
return object;
}
@ -203,6 +206,12 @@ gimp_image_map_tool_finalize (GObject *object)
image_map_tool->operation = NULL;
}
if (image_map_tool->config)
{
g_object_unref (image_map_tool->config);
image_map_tool->config = NULL;
}
if (image_map_tool->shell)
{
gtk_widget_destroy (image_map_tool->shell);
@ -480,7 +489,14 @@ gimp_image_map_tool_dialog (GimpImageMapTool *tool)
static void
gimp_image_map_tool_reset (GimpImageMapTool *tool)
{
if (GIMP_IMAGE_MAP_TOOL_GET_CLASS (tool)->reset)
{
GIMP_IMAGE_MAP_TOOL_GET_CLASS (tool)->reset (tool);
}
else if (tool->config)
{
gimp_config_reset (GIMP_CONFIG (tool->config));
}
}
static void

View File

@ -42,6 +42,7 @@ struct _GimpImageMapTool
GimpDrawable *drawable;
GeglNode *operation;
GObject *config;
GimpImageMapApplyFunc apply_func;
gpointer apply_data;
@ -69,7 +70,8 @@ struct _GimpImageMapToolClass
const gchar *save_dialog_title;
/* virtual functions */
GeglNode * (* get_operation) (GimpImageMapTool *image_map_tool);
GeglNode * (* get_operation) (GimpImageMapTool *image_map_tool,
GObject **config);
void (* map) (GimpImageMapTool *image_map_tool);
void (* dialog) (GimpImageMapTool *image_map_tool);
void (* reset) (GimpImageMapTool *image_map_tool);

View File

@ -22,6 +22,7 @@
#include <gtk/gtk.h>
#include "libgimpmath/gimpmath.h"
#include "libgimpconfig/gimpconfig.h"
#include "libgimpwidgets/gimpwidgets.h"
#include "tools-types.h"
@ -74,7 +75,8 @@ static void gimp_levels_tool_color_picked (GimpColorTool *color_tool
GimpRGB *color,
gint color_index);
static GeglNode * gimp_levels_tool_get_operation (GimpImageMapTool *im_tool);
static GeglNode * gimp_levels_tool_get_operation (GimpImageMapTool *im_tool,
GObject **config);
static void gimp_levels_tool_map (GimpImageMapTool *im_tool);
static void gimp_levels_tool_dialog (GimpImageMapTool *im_tool);
static void gimp_levels_tool_dialog_unmap (GtkWidget *dialog,
@ -86,7 +88,10 @@ static gboolean gimp_levels_tool_settings_load (GimpImageMapTool *im_tool,
static gboolean gimp_levels_tool_settings_save (GimpImageMapTool *im_tool,
gpointer fp);
static void levels_update_adjustments (GimpLevelsTool *tool);
static void gimp_levels_tool_config_notify (GObject *object,
GParamSpec *pspec,
GimpLevelsTool *tool);
static void levels_update_input_bar (GimpLevelsTool *tool);
static void levels_channel_callback (GtkWidget *widget,
@ -184,12 +189,6 @@ gimp_levels_tool_finalize (GObject *object)
{
GimpLevelsTool *tool = GIMP_LEVELS_TOOL (object);
if (tool->config)
{
g_object_unref (tool->config);
tool->config = NULL;
}
gimp_lut_free (tool->lut);
if (tool->hist)
@ -219,11 +218,11 @@ gimp_levels_tool_initialize (GimpTool *tool,
return FALSE;
}
gimp_config_reset (GIMP_CONFIG (l_tool->config));
if (! l_tool->hist)
l_tool->hist = gimp_histogram_new ();
gimp_levels_config_reset (l_tool->config);
l_tool->color = gimp_drawable_is_rgb (drawable);
l_tool->alpha = gimp_drawable_has_alpha (drawable);
@ -236,11 +235,6 @@ gimp_levels_tool_initialize (GimpTool *tool,
gimp_int_combo_box_set_sensitivity (GIMP_INT_COMBO_BOX (l_tool->channel_menu),
levels_menu_sensitivity, l_tool, NULL);
gimp_int_combo_box_set_active (GIMP_INT_COMBO_BOX (l_tool->channel_menu),
l_tool->config->channel);
levels_update_adjustments (l_tool);
gimp_drawable_calculate_histogram (drawable, l_tool->hist);
gimp_histogram_view_set_histogram (GIMP_HISTOGRAM_VIEW (l_tool->hist_view),
l_tool->hist);
@ -249,7 +243,8 @@ gimp_levels_tool_initialize (GimpTool *tool,
}
static GeglNode *
gimp_levels_tool_get_operation (GimpImageMapTool *im_tool)
gimp_levels_tool_get_operation (GimpImageMapTool *im_tool,
GObject **config)
{
GimpLevelsTool *tool = GIMP_LEVELS_TOOL (im_tool);
GeglNode *node;
@ -260,6 +255,12 @@ gimp_levels_tool_get_operation (GimpImageMapTool *im_tool)
tool->config = g_object_new (GIMP_TYPE_LEVELS_CONFIG, NULL);
*config = G_OBJECT (tool->config);
g_signal_connect_object (tool->config, "notify",
G_CALLBACK (gimp_levels_tool_config_notify),
G_OBJECT (tool), 0);
gegl_node_set (node,
"config", tool->config,
NULL);
@ -338,6 +339,7 @@ gimp_levels_tool_dialog (GimpImageMapTool *image_map_tool)
{
GimpLevelsTool *tool = GIMP_LEVELS_TOOL (image_map_tool);
GimpToolOptions *tool_options = GIMP_TOOL_GET_OPTIONS (image_map_tool);
GimpLevelsConfig *config = tool->config;
GtkListStore *store;
GtkWidget *vbox;
GtkWidget *vbox2;
@ -482,7 +484,9 @@ gimp_levels_tool_dialog (GimpImageMapTool *image_map_tool)
gtk_box_pack_start (GTK_BOX (hbox2), button, FALSE, FALSE, 0);
gtk_widget_show (button);
spinbutton = gimp_spin_button_new (&data, 0, 0, 255, 1, 10, 10, 0.5, 0);
spinbutton = gimp_spin_button_new (&data,
config->low_input[config->channel] * 255.0,
0, 255, 1, 10, 10, 0.5, 0);
gtk_box_pack_start (GTK_BOX (hbox2), spinbutton, FALSE, FALSE, 0);
gtk_widget_show (spinbutton);
@ -495,7 +499,9 @@ gimp_levels_tool_dialog (GimpImageMapTool *image_map_tool)
tool->low_input);
/* input gamma spin */
spinbutton = gimp_spin_button_new (&data, 1, 0.1, 10, 0.01, 0.1, 1, 0.5, 2);
spinbutton = gimp_spin_button_new (&data,
config->gamma[config->channel],
0.1, 10, 0.01, 0.1, 1, 0.5, 2);
gtk_box_pack_start (GTK_BOX (hbox), spinbutton, TRUE, FALSE, 0);
gimp_help_set_help_data (spinbutton, _("Gamma"), NULL);
gtk_widget_show (spinbutton);
@ -524,7 +530,9 @@ gimp_levels_tool_dialog (GimpImageMapTool *image_map_tool)
gtk_box_pack_start (GTK_BOX (hbox2), button, FALSE, FALSE, 0);
gtk_widget_show (button);
spinbutton = gimp_spin_button_new (&data, 255, 0, 255, 1, 10, 10, 0.5, 0);
spinbutton = gimp_spin_button_new (&data,
config->high_input[config->channel] * 255.0,
0, 255, 1, 10, 10, 0.5, 0);
gtk_box_pack_start (GTK_BOX (hbox2), spinbutton, FALSE, FALSE, 0);
gtk_widget_show (spinbutton);
@ -584,7 +592,9 @@ gimp_levels_tool_dialog (GimpImageMapTool *image_map_tool)
gtk_widget_show (hbox);
/* low output spin */
spinbutton = gimp_spin_button_new (&data, 0, 0, 255, 1, 10, 10, 0.5, 0);
spinbutton = gimp_spin_button_new (&data,
config->low_output[config->channel] * 255.0,
0, 255, 1, 10, 10, 0.5, 0);
gtk_box_pack_start (GTK_BOX (hbox), spinbutton, FALSE, FALSE, 0);
gtk_widget_show (spinbutton);
@ -597,7 +607,9 @@ gimp_levels_tool_dialog (GimpImageMapTool *image_map_tool)
tool->low_output);
/* high output spin */
spinbutton = gimp_spin_button_new (&data, 255, 0, 255, 1, 10, 10, 0.5, 0);
spinbutton = gimp_spin_button_new (&data,
config->high_output[config->channel] * 255.0,
0, 255, 1, 10, 10, 0.5, 0);
gtk_box_pack_end (GTK_BOX (hbox), spinbutton, FALSE, FALSE, 0);
gtk_widget_show (spinbutton);
@ -664,6 +676,9 @@ gimp_levels_tool_dialog (GimpImageMapTool *image_map_tool)
g_signal_connect (image_map_tool->shell, "unmap",
G_CALLBACK (gimp_levels_tool_dialog_unmap),
tool);
gimp_int_combo_box_set_active (GIMP_INT_COMBO_BOX (tool->channel_menu),
config->channel);
}
static void
@ -681,12 +696,14 @@ gimp_levels_tool_reset (GimpImageMapTool *image_map_tool)
GimpLevelsTool *tool = GIMP_LEVELS_TOOL (image_map_tool);
GimpHistogramChannel channel = tool->config->channel;
gimp_levels_config_reset (tool->config);
g_object_freeze_notify (G_OBJECT (tool->config));
gimp_config_reset (GIMP_CONFIG (tool->config));
g_object_set (tool->config,
"channel", channel,
NULL);
levels_update_adjustments (tool);
g_object_thaw_notify (G_OBJECT (tool->config));
}
static gboolean
@ -696,14 +713,7 @@ gimp_levels_tool_settings_load (GimpImageMapTool *image_map_tool,
{
GimpLevelsTool *tool = GIMP_LEVELS_TOOL (image_map_tool);
if (gimp_levels_config_load_cruft (tool->config, fp, error))
{
levels_update_adjustments (tool);
return TRUE;
}
return FALSE;
return gimp_levels_config_load_cruft (tool->config, fp, error);
}
static gboolean
@ -716,10 +726,28 @@ gimp_levels_tool_settings_save (GimpImageMapTool *image_map_tool,
}
static void
levels_update_adjustments (GimpLevelsTool *tool)
gimp_levels_tool_config_notify (GObject *object,
GParamSpec *pspec,
GimpLevelsTool *tool)
{
GimpLevelsConfig *config = tool->config;
GimpLevelsConfig *config = GIMP_LEVELS_CONFIG (object);
if (! tool->low_input)
return;
if (! strcmp (pspec->name, "channel"))
{
gimp_histogram_view_set_channel (GIMP_HISTOGRAM_VIEW (tool->hist_view),
config->channel);
gimp_color_bar_set_channel (GIMP_COLOR_BAR (tool->output_bar),
config->channel);
gimp_int_combo_box_set_active (GIMP_INT_COMBO_BOX (tool->channel_menu),
config->channel);
}
else if (! strcmp (pspec->name, "gamma") ||
! strcmp (pspec->name, "low-input") ||
! strcmp (pspec->name, "high-input"))
{
tool->low_input->upper = 255;
tool->high_input->lower = 0;
tool->gamma_linear->lower = 0;
@ -740,12 +768,20 @@ levels_update_adjustments (GimpLevelsTool *tool)
gtk_adjustment_changed (tool->high_input);
gtk_adjustment_changed (tool->gamma_linear);
levels_update_input_bar (tool);
}
else if (! strcmp (pspec->name, "low-output"))
{
gtk_adjustment_set_value (tool->low_output,
config->low_output[config->channel] * 255.0);
}
else if (! strcmp (pspec->name, "high-output"))
{
gtk_adjustment_set_value (tool->high_output,
config->high_output[config->channel] * 255.0);
}
levels_update_input_bar (tool);
gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (tool));
}
static void
@ -809,18 +845,12 @@ levels_channel_callback (GtkWidget *widget,
{
gint value;
if (gimp_int_combo_box_get_active (GIMP_INT_COMBO_BOX (widget), &value))
if (gimp_int_combo_box_get_active (GIMP_INT_COMBO_BOX (widget), &value) &&
tool->config->channel != value)
{
g_object_set (tool->config,
"channel", value,
NULL);
gimp_histogram_view_set_channel (GIMP_HISTOGRAM_VIEW (tool->hist_view),
tool->config->channel);
gimp_color_bar_set_channel (GIMP_COLOR_BAR (tool->output_bar),
tool->config->channel);
levels_update_adjustments (tool);
}
}
@ -828,10 +858,7 @@ static void
levels_channel_reset_callback (GtkWidget *widget,
GimpLevelsTool *tool)
{
gimp_levels_config_reset_channel (tool->config, tool->config->channel);
levels_update_adjustments (tool);
gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (tool));
gimp_levels_config_reset_channel (tool->config);
}
static gboolean
@ -866,9 +893,6 @@ levels_stretch_callback (GtkWidget *widget,
GimpLevelsTool *tool)
{
gimp_levels_config_stretch (tool->config, tool->hist, tool->color);
levels_update_adjustments (tool);
gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (tool));
}
static void
@ -922,9 +946,6 @@ levels_low_input_changed (GtkAdjustment *adjustment,
g_object_set (config,
"low-input", value / 255.0,
NULL);
levels_update_input_bar (tool);
gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (tool));
}
levels_linear_gamma_update (tool);
@ -941,9 +962,6 @@ levels_gamma_changed (GtkAdjustment *adjustment,
g_object_set (config,
"gamma", adjustment->value,
NULL);
levels_update_input_bar (tool);
gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (tool));
}
levels_linear_gamma_update (tool);
@ -966,9 +984,6 @@ levels_high_input_changed (GtkAdjustment *adjustment,
g_object_set (config,
"high-input", value / 255.0,
NULL);
levels_update_input_bar (tool);
gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (tool));
}
levels_linear_gamma_update (tool);
@ -986,8 +1001,6 @@ levels_low_output_changed (GtkAdjustment *adjustment,
g_object_set (config,
"low-output", value / 255.0,
NULL);
gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (tool));
}
}
@ -1003,8 +1016,6 @@ levels_high_output_changed (GtkAdjustment *adjustment,
g_object_set (config,
"high-output", value / 255.0,
NULL);
gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (tool));
}
}
@ -1102,8 +1113,4 @@ gimp_levels_tool_color_picked (GimpColorTool *color_tool,
levels_input_adjust_by_color (tool->config,
value, tool->config->channel, color);
}
levels_update_adjustments (tool);
gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (tool));
}

View File

@ -0,0 +1,598 @@
/* GIMP - The GNU Image Manipulation Program
*
* A polygonal selection tool for GIMP
* Copyright (C) 2007 Martin Nordholts
*
* Based on gimpfreeselecttool.c which is
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
#include "libgimpmath/gimpmath.h"
#include "libgimpwidgets/gimpwidgets.h"
#include "tools-types.h"
#include "core/gimpchannel.h"
#include "core/gimpchannel-select.h"
#include "core/gimpimage.h"
#include "core/gimplayer-floating-sel.h"
#include "widgets/gimphelp-ids.h"
#include "display/gimpdisplay.h"
#include "gimppolygonselecttool.h"
#include "gimpselectionoptions.h"
#include "gimptoolcontrol.h"
#include "gimp-intl.h"
#define DEFAULT_MAX_INC 1024
#define POINT_GRAB_THRESHOLD_SQ 100
struct _GimpPolygonSelectTool
{
GimpSelectionTool parent_instance;
/* Point which is part of he polygon already. */
GimpVector2 *grabbed_point;
/* Save the grabbed point state so we can cancel a movement
* operation.
*/
GimpVector2 saved_grabbed_point;
/* Point which is used to draw the polygon but which is not part of
* it yet.
*/
GimpVector2 pending_point;
gboolean show_pending_point;
/* The points of the polygon. */
GimpVector2 *points;
/* The number of points used for the actual selection. */
gint num_points;
gint max_segs;
};
static void gimp_polygon_select_tool_finalize (GObject *object);
static void gimp_polygon_select_tool_control (GimpTool *tool,
GimpToolAction action,
GimpDisplay *display);
static void gimp_polygon_select_tool_oper_update (GimpTool *tool,
GimpCoords *coords,
GdkModifierType state,
gboolean proximity,
GimpDisplay *display);
static void gimp_polygon_select_tool_button_press (GimpTool *tool,
GimpCoords *coords,
guint32 time,
GdkModifierType state,
GimpDisplay *display);
static void gimp_polygon_select_tool_motion (GimpTool *tool,
GimpCoords *coords,
guint32 time,
GdkModifierType state,
GimpDisplay *display);
static void gimp_polygon_select_tool_button_release (GimpTool *tool,
GimpCoords *coords,
guint32 time,
GdkModifierType state,
GimpButtonReleaseType release_type,
GimpDisplay *display);
static gboolean gimp_polygon_select_tool_key_press (GimpTool *tool,
GdkEventKey *kevent,
GimpDisplay *display);
static void gimp_polygon_select_tool_start (GimpPolygonSelectTool *poly_sel_tool,
GimpDisplay *display);
static void gimp_polygon_select_tool_commit (GimpPolygonSelectTool *poly_sel_tool,
GimpDisplay *display);
static void gimp_polygon_select_tool_halt (GimpPolygonSelectTool *poly_sel_tool);
static void gimp_polygon_select_tool_draw (GimpDrawTool *draw_tool);
static void gimp_polygon_select_tool_real_select (GimpPolygonSelectTool *poly_sel_tool,
GimpDisplay *display);
static GimpVector2 *gimp_polygon_select_tool_add_point (GimpPolygonSelectTool *poly_sel_tool,
gdouble x,
gdouble y);
static void gimp_polygon_select_tool_remove_last (GimpPolygonSelectTool *poly_sel_tool);
static void gimp_polygon_select_tool_select_closet_point
(GimpPolygonSelectTool *poly_sel_tool,
GimpDisplay *display,
GimpCoords *coords);
static gboolean gimp_polygon_select_tool_should_close (GimpPolygonSelectTool *poly_sel_tool,
GimpDisplay *display,
GimpCoords *coords);
G_DEFINE_TYPE (GimpPolygonSelectTool, gimp_polygon_select_tool,
GIMP_TYPE_SELECTION_TOOL);
#define parent_class gimp_polygon_select_tool_parent_class
void
gimp_polygon_select_tool_register (GimpToolRegisterCallback callback,
gpointer data)
{
(* callback) (GIMP_TYPE_POLYGON_SELECT_TOOL,
GIMP_TYPE_SELECTION_OPTIONS,
gimp_selection_options_gui,
0,
"gimp-polygon-select-tool",
_("Polygon Select"),
_("Polygon Select Tool: Select a hand-drawn polygon"),
N_("_Polygon Select"), "G",
NULL, GIMP_HELP_TOOL_POLYGON_SELECT,
GIMP_STOCK_TOOL_POLYGON_SELECT,
data);
}
static void
gimp_polygon_select_tool_class_init (GimpPolygonSelectToolClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GimpToolClass *tool_class = GIMP_TOOL_CLASS (klass);
GimpDrawToolClass *draw_tool_class = GIMP_DRAW_TOOL_CLASS (klass);
object_class->finalize = gimp_polygon_select_tool_finalize;
tool_class->control = gimp_polygon_select_tool_control;
tool_class->oper_update = gimp_polygon_select_tool_oper_update;
tool_class->button_press = gimp_polygon_select_tool_button_press;
tool_class->motion = gimp_polygon_select_tool_motion;
tool_class->button_release = gimp_polygon_select_tool_button_release;
tool_class->key_press = gimp_polygon_select_tool_key_press;
draw_tool_class->draw = gimp_polygon_select_tool_draw;
klass->select = gimp_polygon_select_tool_real_select;
}
static void
gimp_polygon_select_tool_init (GimpPolygonSelectTool *poly_sel_tool)
{
GimpTool *tool = GIMP_TOOL (poly_sel_tool);
gimp_tool_control_set_scroll_lock (tool->control, FALSE);
gimp_tool_control_set_wants_click (tool->control, TRUE);
gimp_tool_control_set_tool_cursor (tool->control,
GIMP_TOOL_CURSOR_FREE_SELECT);
poly_sel_tool->points = NULL;
poly_sel_tool->max_segs = 0;
}
static void
gimp_polygon_select_tool_finalize (GObject *object)
{
GimpPolygonSelectTool *poly_sel_tool = GIMP_POLYGON_SELECT_TOOL (object);
if (poly_sel_tool->points)
{
g_free (poly_sel_tool->points);
poly_sel_tool->points = NULL;
}
G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
gimp_polygon_select_tool_control (GimpTool *tool,
GimpToolAction action,
GimpDisplay *display)
{
switch (action)
{
case GIMP_TOOL_ACTION_PAUSE:
case GIMP_TOOL_ACTION_RESUME:
break;
case GIMP_TOOL_ACTION_HALT:
gimp_polygon_select_tool_halt (GIMP_POLYGON_SELECT_TOOL (tool));
break;
}
GIMP_TOOL_CLASS (parent_class)->control (tool, action, display);
}
static void
gimp_polygon_select_tool_oper_update (GimpTool *tool,
GimpCoords *coords,
GdkModifierType state,
gboolean proximity,
GimpDisplay *display)
{
GimpPolygonSelectTool *poly_sel_tool = GIMP_POLYGON_SELECT_TOOL (tool);
if (tool->display == display)
{
gimp_polygon_select_tool_select_closet_point (poly_sel_tool,
display,
coords);
gimp_draw_tool_pause (GIMP_DRAW_TOOL (tool));
if (poly_sel_tool->grabbed_point || poly_sel_tool->num_points == 0)
{
poly_sel_tool->show_pending_point = FALSE;
}
else
{
poly_sel_tool->show_pending_point = TRUE;
poly_sel_tool->pending_point.x = coords->x;
poly_sel_tool->pending_point.y = coords->y;
}
gimp_draw_tool_resume (GIMP_DRAW_TOOL (tool));
}
}
static void
gimp_polygon_select_tool_button_press (GimpTool *tool,
GimpCoords *coords,
guint32 time,
GdkModifierType state,
GimpDisplay *display)
{
GimpPolygonSelectTool *poly_sel_tool = GIMP_POLYGON_SELECT_TOOL (tool);
if (display != tool->display)
{
gimp_polygon_select_tool_start (poly_sel_tool, display);
gimp_selection_tool_start_edit (GIMP_SELECTION_TOOL (poly_sel_tool),
coords);
}
if (poly_sel_tool->grabbed_point)
{
poly_sel_tool->saved_grabbed_point = *poly_sel_tool->grabbed_point;
}
}
static void
gimp_polygon_select_tool_motion (GimpTool *tool,
GimpCoords *coords,
guint32 time,
GdkModifierType state,
GimpDisplay *display)
{
if (tool->display == display)
{
GimpPolygonSelectTool *poly_sel_tool = GIMP_POLYGON_SELECT_TOOL (tool);
GimpDrawTool *draw_tool = GIMP_DRAW_TOOL (tool);
gimp_draw_tool_pause (draw_tool);
if (poly_sel_tool->grabbed_point)
{
poly_sel_tool->grabbed_point->x = coords->x;
poly_sel_tool->grabbed_point->y = coords->y;
}
else
{
poly_sel_tool->pending_point.x = coords->x;
poly_sel_tool->pending_point.y = coords->y;
}
gimp_draw_tool_resume (draw_tool);
}
}
static void
gimp_polygon_select_tool_button_release (GimpTool *tool,
GimpCoords *coords,
guint32 time,
GdkModifierType state,
GimpButtonReleaseType release_type,
GimpDisplay *display)
{
GimpPolygonSelectTool *poly_sel_tool = GIMP_POLYGON_SELECT_TOOL (tool);
switch (release_type)
{
case GIMP_BUTTON_RELEASE_CLICK:
if (gimp_polygon_select_tool_should_close (poly_sel_tool,
display,
coords))
{
gimp_polygon_select_tool_commit (poly_sel_tool,
display);
break;
}
/* Fall through */
case GIMP_BUTTON_RELEASE_NORMAL:
if (! poly_sel_tool->grabbed_point)
{
gimp_polygon_select_tool_add_point (poly_sel_tool, coords->x, coords->y);
}
else
{
/* We don't need to do anything since the grabbed point have
* already been moved in _motion.
*/
}
break;
case GIMP_BUTTON_RELEASE_CANCEL:
{
gimp_draw_tool_pause (GIMP_DRAW_TOOL (poly_sel_tool));
if (poly_sel_tool->grabbed_point)
{
*poly_sel_tool->grabbed_point = poly_sel_tool->saved_grabbed_point;
}
gimp_draw_tool_resume (GIMP_DRAW_TOOL (poly_sel_tool));
}
break;
case GIMP_BUTTON_RELEASE_NO_MOTION:
if (gimp_image_floating_sel (display->image))
{
/* If there is a floating selection, anchor it */
floating_sel_anchor (gimp_image_floating_sel (display->image));
}
else
{
/* Otherwise, clear the selection mask */
gimp_channel_clear (gimp_image_get_mask (display->image), NULL, TRUE);
}
break;
}
}
static gboolean
gimp_polygon_select_tool_key_press (GimpTool *tool,
GdkEventKey *kevent,
GimpDisplay *display)
{
GimpPolygonSelectTool *poly_sel_tool = GIMP_POLYGON_SELECT_TOOL (tool);
gboolean handled_key = FALSE;
switch (kevent->keyval)
{
case GDK_BackSpace:
gimp_polygon_select_tool_remove_last (poly_sel_tool);
handled_key = TRUE;
break;
case GDK_KP_Enter:
case GDK_Return:
gimp_polygon_select_tool_commit (poly_sel_tool, display);
handled_key = TRUE;
break;
case GDK_Escape:
gimp_polygon_select_tool_halt (poly_sel_tool);
handled_key = TRUE;
break;
default:
handled_key = FALSE;
break;
}
return handled_key;
}
static void
gimp_polygon_select_tool_start (GimpPolygonSelectTool *poly_sel_tool,
GimpDisplay *display)
{
GimpTool *tool = GIMP_TOOL (poly_sel_tool);
GimpDrawTool *draw_tool = GIMP_DRAW_TOOL (tool);
gimp_polygon_select_tool_halt (poly_sel_tool);
gimp_tool_control_activate (tool->control);
tool->display = display;
poly_sel_tool->num_points = 0;
poly_sel_tool->grabbed_point = NULL;
poly_sel_tool->show_pending_point = FALSE;
gimp_draw_tool_start (draw_tool, display);
}
static void
gimp_polygon_select_tool_commit (GimpPolygonSelectTool *poly_sel_tool,
GimpDisplay *display)
{
gimp_polygon_select_tool_select (poly_sel_tool, display);
gimp_polygon_select_tool_halt (poly_sel_tool);
}
static void
gimp_polygon_select_tool_halt (GimpPolygonSelectTool *poly_sel_tool)
{
GimpTool *tool = GIMP_TOOL (poly_sel_tool);
GimpDrawTool *draw_tool = GIMP_DRAW_TOOL (poly_sel_tool);
if (gimp_draw_tool_is_active (draw_tool))
gimp_draw_tool_stop (draw_tool);
if (gimp_tool_control_is_active (tool->control))
gimp_tool_control_halt (tool->control);
poly_sel_tool->grabbed_point = NULL;
poly_sel_tool->show_pending_point = FALSE;
poly_sel_tool->num_points = 0;
tool->display = NULL;
}
static void
gimp_polygon_select_tool_draw (GimpDrawTool *draw_tool)
{
GimpPolygonSelectTool *poly_sel_tool = GIMP_POLYGON_SELECT_TOOL (draw_tool);
gimp_draw_tool_draw_lines (draw_tool,
(const gdouble *) poly_sel_tool->points,
poly_sel_tool->num_points,
FALSE, FALSE);
if (poly_sel_tool->show_pending_point)
{
gimp_draw_tool_draw_line (draw_tool,
poly_sel_tool->points[poly_sel_tool->num_points - 1].x,
poly_sel_tool->points[poly_sel_tool->num_points - 1].y,
poly_sel_tool->pending_point.x,
poly_sel_tool->pending_point.y,
FALSE);
}
}
void
gimp_polygon_select_tool_select (GimpPolygonSelectTool *poly_sel_tool,
GimpDisplay *display)
{
g_return_if_fail (GIMP_IS_POLYGON_SELECT_TOOL (poly_sel_tool));
g_return_if_fail (GIMP_IS_DISPLAY (display));
GIMP_POLYGON_SELECT_TOOL_GET_CLASS (poly_sel_tool)->select (poly_sel_tool, display);
}
static void
gimp_polygon_select_tool_real_select (GimpPolygonSelectTool *poly_sel_tool,
GimpDisplay *display)
{
GimpSelectionOptions *options = GIMP_SELECTION_TOOL_GET_OPTIONS (poly_sel_tool);
gimp_channel_select_polygon (gimp_image_get_mask (display->image),
Q_("command|Polygon Select"),
poly_sel_tool->num_points,
poly_sel_tool->points,
options->operation,
options->antialias,
options->feather,
options->feather_radius,
options->feather_radius,
TRUE);
}
static GimpVector2 *
gimp_polygon_select_tool_add_point (GimpPolygonSelectTool *poly_sel_tool,
gdouble x,
gdouble y)
{
if (poly_sel_tool->num_points >= poly_sel_tool->max_segs)
{
poly_sel_tool->max_segs += DEFAULT_MAX_INC;
poly_sel_tool->points = g_realloc (poly_sel_tool->points,
sizeof (GimpVector2) * poly_sel_tool->max_segs);
}
poly_sel_tool->points[poly_sel_tool->num_points].x = x;
poly_sel_tool->points[poly_sel_tool->num_points].y = y;
return &poly_sel_tool->points[poly_sel_tool->num_points++];
}
static void
gimp_polygon_select_tool_remove_last (GimpPolygonSelectTool *poly_sel_tool)
{
GimpDrawTool *draw_tool = GIMP_DRAW_TOOL (poly_sel_tool);
gimp_draw_tool_pause (draw_tool);
if (poly_sel_tool->num_points == 0)
{
gimp_polygon_select_tool_halt (poly_sel_tool);
}
else
{
poly_sel_tool->num_points--;
}
gimp_draw_tool_resume (draw_tool);
}
static void
gimp_polygon_select_tool_select_closet_point (GimpPolygonSelectTool *poly_sel_tool,
GimpDisplay *display,
GimpCoords *coords)
{
GimpDrawTool *draw_tool = GIMP_DRAW_TOOL (poly_sel_tool);
gdouble shortest_dist_sq;
int i;
poly_sel_tool->grabbed_point = NULL;
shortest_dist_sq = POINT_GRAB_THRESHOLD_SQ;
for (i = 0; i < poly_sel_tool->num_points; i++)
{
gdouble dist_sq;
dist_sq = gimp_draw_tool_calc_distance_square (draw_tool,
display,
coords->x,
coords->y,
poly_sel_tool->points[i].x,
poly_sel_tool->points[i].y);
if (dist_sq < shortest_dist_sq)
{
poly_sel_tool->grabbed_point = &poly_sel_tool->points[i];
}
}
}
static gboolean
gimp_polygon_select_tool_should_close (GimpPolygonSelectTool *poly_sel_tool,
GimpDisplay *display,
GimpCoords *coords)
{
gboolean should_close = FALSE;
if (poly_sel_tool->num_points > 0)
{
gdouble dist_sq;
dist_sq = gimp_draw_tool_calc_distance_square (GIMP_DRAW_TOOL (poly_sel_tool),
display,
coords->x,
coords->y,
poly_sel_tool->points[0].x,
poly_sel_tool->points[0].y);
should_close = dist_sq < POINT_GRAB_THRESHOLD_SQ;
}
return should_close;
}

View File

@ -0,0 +1,62 @@
/* GIMP - The GNU Image Manipulation Program
*
* A polygonal selection tool for GIMP
* Copyright (C) 2007 Martin Nordholts
*
* Based on gimpfreeselecttool.h which is
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef GIMP_POLYGON_SELECT_TOOL_H
#define GIMP_POLYGON_SELECT_TOOL_H
#include "gimpselectiontool.h"
#define GIMP_TYPE_POLYGON_SELECT_TOOL (gimp_polygon_select_tool_get_type ())
#define GIMP_POLYGON_SELECT_TOOL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_POLYGON_SELECT_TOOL, GimpPolygonSelectTool))
#define GIMP_POLYGON_SELECT_TOOL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_POLYGON_SELECT_TOOL, GimpPolygonSelectToolClass))
#define GIMP_IS_POLYGON_SELECT_TOOL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_POLYGON_SELECT_TOOL))
#define GIMP_IS_POLYGON_SELECT_TOOL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_POLYGON_SELECT_TOOL))
#define GIMP_POLYGON_SELECT_TOOL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_POLYGON_SELECT_TOOL, GimpPolygonSelectToolClass))
typedef struct _GimpPolygonSelectTool GimpPolygonSelectTool;
typedef struct _GimpPolygonSelectToolClass GimpPolygonSelectToolClass;
struct _GimpPolygonSelectToolClass
{
GimpSelectionToolClass parent_class;
/* virtual function */
void (* select) (GimpPolygonSelectTool *poly_select_tool,
GimpDisplay *display);
};
void gimp_polygon_select_tool_register (GimpToolRegisterCallback callback,
gpointer data);
GType gimp_polygon_select_tool_get_type (void) G_GNUC_CONST;
void gimp_polygon_select_tool_select (GimpPolygonSelectTool *poly_sel,
GimpDisplay *display);
#endif /* GIMP_POLYGON_SELECT_TOOL_H */

View File

@ -21,6 +21,8 @@
#include <gegl.h>
#include <gtk/gtk.h>
#include "libgimpmath/gimpmath.h"
#include "libgimpconfig/gimpconfig.h"
#include "libgimpwidgets/gimpwidgets.h"
#include "tools-types.h"
@ -28,6 +30,8 @@
#include "base/gimplut.h"
#include "base/lut-funcs.h"
#include "gegl/gimpposterizeconfig.h"
#include "core/gimpdrawable.h"
#include "core/gimpimage.h"
@ -41,8 +45,6 @@
#include "gimp-intl.h"
#define POSTERIZE_DEFAULT_LEVELS 3
#define SLIDER_WIDTH 200
@ -52,10 +54,14 @@ static gboolean gimp_posterize_tool_initialize (GimpTool *tool,
GimpDisplay *display,
GError **error);
static GeglNode * gimp_posterize_tool_get_operation (GimpImageMapTool *im_tool);
static GeglNode * gimp_posterize_tool_get_operation (GimpImageMapTool *im_tool,
GObject **config);
static void gimp_posterize_tool_map (GimpImageMapTool *im_tool);
static void gimp_posterize_tool_dialog (GimpImageMapTool *im_tool);
static void gimp_posterize_tool_reset (GimpImageMapTool *im_tool);
static void gimp_posterize_tool_config_notify (GObject *object,
GParamSpec *pspec,
GimpPosterizeTool *posterize_tool);
static void gimp_posterize_tool_levels_changed (GtkAdjustment *adjustment,
GimpPosterizeTool *posterize_tool);
@ -99,7 +105,6 @@ gimp_posterize_tool_class_init (GimpPosterizeToolClass *klass)
im_tool_class->get_operation = gimp_posterize_tool_get_operation;
im_tool_class->map = gimp_posterize_tool_map;
im_tool_class->dialog = gimp_posterize_tool_dialog;
im_tool_class->reset = gimp_posterize_tool_reset;
}
static void
@ -107,7 +112,6 @@ gimp_posterize_tool_init (GimpPosterizeTool *posterize_tool)
{
GimpImageMapTool *im_tool = GIMP_IMAGE_MAP_TOOL (posterize_tool);
posterize_tool->levels = POSTERIZE_DEFAULT_LEVELS;
posterize_tool->lut = gimp_lut_new ();
im_tool->apply_func = (GimpImageMapApplyFunc) gimp_lut_process;
@ -148,12 +152,12 @@ gimp_posterize_tool_initialize (GimpTool *tool,
return FALSE;
}
posterize_tool->levels = POSTERIZE_DEFAULT_LEVELS;
gimp_config_reset (GIMP_CONFIG (posterize_tool->config));
GIMP_TOOL_CLASS (parent_class)->initialize (tool, display, error);
gtk_adjustment_set_value (posterize_tool->levels_data,
posterize_tool->levels);
posterize_tool->config->levels);
gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (posterize_tool));
@ -161,11 +165,29 @@ gimp_posterize_tool_initialize (GimpTool *tool,
}
static GeglNode *
gimp_posterize_tool_get_operation (GimpImageMapTool *im_tool)
gimp_posterize_tool_get_operation (GimpImageMapTool *image_map_tool,
GObject **config)
{
return g_object_new (GEGL_TYPE_NODE,
GimpPosterizeTool *posterize_tool = GIMP_POSTERIZE_TOOL (image_map_tool);
GeglNode *node;
node = g_object_new (GEGL_TYPE_NODE,
"operation", "gimp-posterize",
NULL);
posterize_tool->config = g_object_new (GIMP_TYPE_POSTERIZE_CONFIG, NULL);
*config = G_OBJECT (posterize_tool->config);
g_signal_connect_object (posterize_tool->config, "notify",
G_CALLBACK (gimp_posterize_tool_config_notify),
G_OBJECT (posterize_tool), 0);
gegl_node_set (node,
"config", posterize_tool->config,
NULL);
return node;
}
static void
@ -173,12 +195,8 @@ gimp_posterize_tool_map (GimpImageMapTool *image_map_tool)
{
GimpPosterizeTool *posterize_tool = GIMP_POSTERIZE_TOOL (image_map_tool);
gegl_node_set (image_map_tool->operation,
"levels", posterize_tool->levels,
NULL);
posterize_lut_setup (posterize_tool->lut,
posterize_tool->levels,
posterize_tool->config->levels,
gimp_drawable_bytes (image_map_tool->drawable));
}
@ -204,7 +222,7 @@ gimp_posterize_tool_dialog (GimpImageMapTool *image_map_tool)
data = gimp_scale_entry_new (GTK_TABLE (table), 0, 0,
_("Posterize _levels:"), SLIDER_WIDTH, -1,
posterize_tool->levels,
posterize_tool->config->levels,
2.0, 256.0, 1.0, 10.0, 0,
TRUE, 0.0, 0.0,
NULL, NULL);
@ -218,24 +236,31 @@ gimp_posterize_tool_dialog (GimpImageMapTool *image_map_tool)
}
static void
gimp_posterize_tool_reset (GimpImageMapTool *image_map_tool)
gimp_posterize_tool_config_notify (GObject *object,
GParamSpec *pspec,
GimpPosterizeTool *posterize_tool)
{
GimpPosterizeTool *posterize_tool = GIMP_POSTERIZE_TOOL (image_map_tool);
GimpPosterizeConfig *config = GIMP_POSTERIZE_CONFIG (object);
posterize_tool->levels = POSTERIZE_DEFAULT_LEVELS;
if (! posterize_tool->levels_data)
return;
gtk_adjustment_set_value (posterize_tool->levels_data,
posterize_tool->levels);
gtk_adjustment_set_value (posterize_tool->levels_data, config->levels);
gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (posterize_tool));
}
static void
gimp_posterize_tool_levels_changed (GtkAdjustment *adjustment,
GimpPosterizeTool *posterize_tool)
{
if (posterize_tool->levels != adjustment->value)
{
posterize_tool->levels = adjustment->value;
GimpPosterizeConfig *config = posterize_tool->config;
gint value = ROUND (adjustment->value);
gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (posterize_tool));
if (config->levels != value)
{
g_object_set (config,
"levels", value,
NULL);
}
}

View File

@ -38,7 +38,7 @@ struct _GimpPosterizeTool
{
GimpImageMapTool parent_instance;
gint levels;
GimpPosterizeConfig *config;
GimpLut *lut;
/* dialog */

View File

@ -21,6 +21,7 @@
#include <gegl.h>
#include <gtk/gtk.h>
#include "libgimpconfig/gimpconfig.h"
#include "libgimpwidgets/gimpwidgets.h"
#include "tools-types.h"
@ -54,10 +55,14 @@ static gboolean gimp_threshold_tool_initialize (GimpTool *tool,
GimpDisplay *display,
GError **error);
static GeglNode * gimp_threshold_tool_get_operation (GimpImageMapTool *im_tool);
static GeglNode * gimp_threshold_tool_get_operation (GimpImageMapTool *im_tool,
GObject **config);
static void gimp_threshold_tool_map (GimpImageMapTool *im_tool);
static void gimp_threshold_tool_dialog (GimpImageMapTool *im_tool);
static void gimp_threshold_tool_reset (GimpImageMapTool *im_tool);
static void gimp_threshold_tool_config_notify (GObject *object,
GParamSpec *pspec,
GimpThresholdTool *t_tool);
static void gimp_threshold_tool_histogram_range (GimpHistogramView *view,
gint start,
@ -106,7 +111,6 @@ gimp_threshold_tool_class_init (GimpThresholdToolClass *klass)
im_tool_class->get_operation = gimp_threshold_tool_get_operation;
im_tool_class->map = gimp_threshold_tool_map;
im_tool_class->dialog = gimp_threshold_tool_dialog;
im_tool_class->reset = gimp_threshold_tool_reset;
}
static void
@ -126,12 +130,6 @@ gimp_threshold_tool_finalize (GObject *object)
{
GimpThresholdTool *t_tool = GIMP_THRESHOLD_TOOL (object);
if (t_tool->config)
{
g_object_unref (t_tool->config);
t_tool->config = NULL;
}
g_slice_free (Threshold, t_tool->threshold);
if (t_tool->hist)
@ -161,11 +159,11 @@ gimp_threshold_tool_initialize (GimpTool *tool,
return FALSE;
}
gimp_config_reset (GIMP_CONFIG (t_tool->config));
if (! t_tool->hist)
t_tool->hist = gimp_histogram_new ();
gimp_threshold_config_reset (t_tool->config);
t_tool->threshold->color = gimp_drawable_is_rgb (drawable);
GIMP_TOOL_CLASS (parent_class)->initialize (tool, display, error);
@ -190,7 +188,8 @@ gimp_threshold_tool_initialize (GimpTool *tool,
}
static GeglNode *
gimp_threshold_tool_get_operation (GimpImageMapTool *image_map_tool)
gimp_threshold_tool_get_operation (GimpImageMapTool *image_map_tool,
GObject **config)
{
GimpThresholdTool *t_tool = GIMP_THRESHOLD_TOOL (image_map_tool);
GeglNode *node;
@ -201,6 +200,12 @@ gimp_threshold_tool_get_operation (GimpImageMapTool *image_map_tool)
t_tool->config = g_object_new (GIMP_TYPE_THRESHOLD_CONFIG, NULL);
*config = G_OBJECT (t_tool->config);
g_signal_connect_object (t_tool->config, "notify",
G_CALLBACK (gimp_threshold_tool_config_notify),
G_OBJECT (t_tool), 0);
gegl_node_set (node,
"config", t_tool->config,
NULL);
@ -273,15 +278,18 @@ gimp_threshold_tool_dialog (GimpImageMapTool *image_map_tool)
}
static void
gimp_threshold_tool_reset (GimpImageMapTool *image_map_tool)
gimp_threshold_tool_config_notify (GObject *object,
GParamSpec *pspec,
GimpThresholdTool *t_tool)
{
GimpThresholdTool *t_tool = GIMP_THRESHOLD_TOOL (image_map_tool);
gimp_threshold_config_reset (t_tool->config);
GimpThresholdConfig *config = GIMP_THRESHOLD_CONFIG (object);
if (t_tool->histogram_box)
gimp_histogram_view_set_range (t_tool->histogram_box->view,
t_tool->config->low * 255.999,
t_tool->config->high * 255.999);
config->low * 255.999,
config->high * 255.999);
gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (t_tool));
}
static void
@ -300,8 +308,6 @@ gimp_threshold_tool_histogram_range (GimpHistogramView *widget,
"low", low,
"high", high,
NULL);
gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (t_tool));
}
}

View File

@ -270,6 +270,7 @@
#define GIMP_HELP_TOOL_PENCIL "gimp-tool-pencil"
#define GIMP_HELP_TOOL_PERSPECTIVE "gimp-tool-perspective"
#define GIMP_HELP_TOOL_PERSPECTIVE_CLONE "gimp-tool-perspective-clone"
#define GIMP_HELP_TOOL_POLYGON_SELECT "gimp-tool-polygon-select"
#define GIMP_HELP_TOOL_POSTERIZE "gimp-tool-posterize"
#define GIMP_HELP_TOOL_RECT_SELECT "gimp-tool-rect-select"
#define GIMP_HELP_TOOL_ROTATE "gimp-tool-rotate"

View File

@ -623,6 +623,7 @@ gimp_histogram_view_set_channel (GimpHistogramView *view,
{
g_return_if_fail (GIMP_IS_HISTOGRAM_VIEW (view));
if (channel != view->channel)
g_object_set (view, "histogram-channel", channel, NULL);
}
@ -640,6 +641,7 @@ gimp_histogram_view_set_scale (GimpHistogramView *view,
{
g_return_if_fail (GIMP_IS_HISTOGRAM_VIEW (view));
if (scale != view->scale)
g_object_set (view, "histogram-scale", scale, NULL);
}
@ -658,6 +660,9 @@ gimp_histogram_view_set_range (GimpHistogramView *view,
{
g_return_if_fail (GIMP_IS_HISTOGRAM_VIEW (view));
if (view->start != MIN (start, end) ||
view->end != MAX (start, end))
{
view->start = MIN (start, end);
view->end = MAX (start, end);
@ -665,6 +670,7 @@ gimp_histogram_view_set_range (GimpHistogramView *view,
g_signal_emit (view, histogram_view_signals[RANGE_CHANGED], 0,
view->start, view->end);
}
}
void

View File

@ -143,8 +143,9 @@ gimp_config_serialize_changed_properties (GimpConfig *config,
}
/**
* gimp_config_serialize_properties:
* gimp_config_serialize_property:
* @config: a #GimpConfig.
* @param_spec: a #GParamSpec.
* @writer: a #GimpConfigWriter.
*
* This function serializes a single object property to the @writer.

View File

@ -313,6 +313,7 @@ static const GtkStockItem gimp_stock_items[] =
{ GIMP_STOCK_TOOL_PENCIL, NULL, 0, 0, LIBGIMP_DOMAIN },
{ GIMP_STOCK_TOOL_PERSPECTIVE, N_("_Transform"), 0, 0, LIBGIMP_DOMAIN },
{ GIMP_STOCK_TOOL_PERSPECTIVE_CLONE, NULL, 0, 0, LIBGIMP_DOMAIN },
{ GIMP_STOCK_TOOL_POLYGON_SELECT, NULL, 0, 0, LIBGIMP_DOMAIN },
{ GIMP_STOCK_TOOL_POSTERIZE, NULL, 0, 0, LIBGIMP_DOMAIN },
{ GIMP_STOCK_TOOL_RECT_SELECT, NULL, 0, 0, LIBGIMP_DOMAIN },
{ GIMP_STOCK_TOOL_ROTATE, N_("_Rotate"), 0, 0, LIBGIMP_DOMAIN },
@ -463,6 +464,7 @@ gimp_stock_button_pixbufs[] =
{ GIMP_STOCK_TOOL_PENCIL, stock_tool_pencil_22 },
{ GIMP_STOCK_TOOL_PERSPECTIVE, stock_tool_perspective_22 },
{ GIMP_STOCK_TOOL_PERSPECTIVE_CLONE, stock_tool_perspective_clone_22 },
{ GIMP_STOCK_TOOL_POLYGON_SELECT, stock_tool_polygon_select_22 },
{ GIMP_STOCK_TOOL_POSTERIZE, stock_tool_posterize_22 },
{ GIMP_STOCK_TOOL_RECT_SELECT, stock_tool_rect_select_22 },
{ GIMP_STOCK_TOOL_ROTATE, stock_tool_rotate_22 },
@ -624,6 +626,7 @@ gimp_stock_menu_pixbufs[] =
{ GIMP_STOCK_TOOL_PENCIL, stock_tool_pencil_16 },
{ GIMP_STOCK_TOOL_PERSPECTIVE, stock_tool_perspective_16 },
{ GIMP_STOCK_TOOL_PERSPECTIVE_CLONE, stock_tool_perspective_clone_16 },
{ GIMP_STOCK_TOOL_POLYGON_SELECT, stock_tool_polygon_select_16 },
{ GIMP_STOCK_TOOL_POSTERIZE, stock_tool_posterize_16 },
{ GIMP_STOCK_TOOL_RECT_SELECT, stock_tool_rect_select_16 },
{ GIMP_STOCK_TOOL_ROTATE, stock_tool_rotate_16 },

View File

@ -130,6 +130,7 @@ G_BEGIN_DECLS
#define GIMP_STOCK_TOOL_PENCIL "gimp-tool-pencil"
#define GIMP_STOCK_TOOL_PERSPECTIVE "gimp-tool-perspective"
#define GIMP_STOCK_TOOL_PERSPECTIVE_CLONE "gimp-tool-perspective-clone"
#define GIMP_STOCK_TOOL_POLYGON_SELECT "gimp-tool-polygon-select"
#define GIMP_STOCK_TOOL_POSTERIZE "gimp-tool-posterize"
#define GIMP_STOCK_TOOL_RECT_SELECT "gimp-tool-rect-select"
#define GIMP_STOCK_TOOL_ROTATE "gimp-tool-rotate"

View File

@ -494,6 +494,7 @@
<menuitem action="tools-rect-select" />
<menuitem action="tools-ellipse-select" />
<menuitem action="tools-free-select" />
<menuitem action="tools-polygon-select" />
<menuitem action="tools-foreground-select" />
<menuitem action="tools-fuzzy-select" />
<menuitem action="tools-by-color-select" />

View File

@ -64,7 +64,7 @@ enum
#define NUM_EVENTS_PER_SLIDER 2 /* Slider decrease and increase */
#define NUM_EVENTS_PER_POV 3 /* POV view vector X and Y view and return */
#define CONTROLLER_TYPE_DX_DINPUT (controller_dx_input_get_type ())
#define CONTROLLER_TYPE_DX_DINPUT (controller_dx_dinput_get_type ())
#define CONTROLLER_DX_DINPUT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CONTROLLER_TYPE_DX_DINPUT, ControllerDXDInput))
#define CONTROLLER_DX_DINPUT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CONTROLLER_TYPE_DX_DINPUT, ControllerDXDInputClass))
#define CONTROLLER_IS_DX_DINPUT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CONTROLLER_TYPE_DX_DINPUT))
@ -161,7 +161,7 @@ static const GimpModuleInfo dx_dinput_info =
};
G_DEFINE_DYNAMIC_TYPE (ControllerDXInput, controller_dx_input,
G_DEFINE_DYNAMIC_TYPE (ControllerDXDInput, controller_dx_dinput,
GIMP_TYPE_CONTROLLER)
@ -240,7 +240,7 @@ dx_dinput_dispose (GObject *object)
dx_dinput_set_device (controller, NULL);
G_OBJECT_CLASS (controller_dx_input_parent_class)->dispose (object);
G_OBJECT_CLASS (controller_dx_dinput_parent_class)->dispose (object);
}
static void
@ -280,7 +280,7 @@ dx_dinput_finalize (GObject *object)
controller->store = NULL;
}
G_OBJECT_CLASS (controller_dx_input_parent_class)->finalize (object);
G_OBJECT_CLASS (controller_dx_dinput_parent_class)->finalize (object);
}
static void
@ -892,7 +892,6 @@ dump_data_format (const DIDATAFORMAT *format)
#undef BIT
g_print ("\n");
g_print (" dwFlags:");
#define BIT(x) if (oformat->dwFlags & DIDOI_ASPECT##x) g_print (" DIDOI_ASPECT"#x)
switch (oformat->dwFlags & DIDOI_ASPECTACCEL)
{
case DIDOI_ASPECTPOSITION: g_print (" DIDOI_ASPECTPOSITION"); break;

View File

@ -430,6 +430,7 @@ cubism (GimpDrawable *drawable,
for (i = 0; i < bytes; i++)
*dest++ = bg_col[i];
}
dest = NULL;
}
@ -440,11 +441,10 @@ cubism (GimpDrawable *drawable,
randomize_indices (num_tiles, random_indices);
count = 0;
gimp_pixel_rgn_init (&src_rgn, drawable,
x1, y1, x2 - x1, y2 - y1, FALSE, FALSE);
while (count < num_tiles)
for (count = 0; count < num_tiles; count++)
{
i = random_indices[count] / (cols + 1);
j = random_indices[count] % (cols + 1);
@ -473,14 +473,13 @@ cubism (GimpDrawable *drawable,
gimp_pixel_rgn_get_pixel (&src_rgn, col, ix, iy);
if (!has_alpha || col[bytes - 1])
if (! has_alpha || col[bytes - 1])
fill_poly_color (&poly, drawable, preview, col, dest);
count++;
if (!preview)
if (! preview)
{
if ((count % 5) == 0)
gimp_progress_update ((double) count / (double) num_tiles);
if (count % 8 == 0)
gimp_progress_update ((gdouble) count / (gdouble) num_tiles);
}
}
@ -510,17 +509,12 @@ calc_alpha_blend (gdouble *vec,
{
gdouble r;
if (!one_over_dist)
if (! one_over_dist)
return 1.0;
else
{
r = (vec[0] * x + vec[1] * y) * one_over_dist;
if (r < 0.2)
r = 0.2;
else if (r > 1.0)
r = 1.0;
}
return r;
return CLAMP (r, 0.2, 1.0);
}
static void
@ -611,8 +605,8 @@ fill_poly_color (Polygon *poly,
if (poly->npts)
{
gint poly_npts = poly->npts;
GimpVector2 *curptr;
gint poly_npts = poly->npts;
xs = (gint) (poly->pts[poly_npts-1].x);
ys = (gint) (poly->pts[poly_npts-1].y);
@ -685,7 +679,10 @@ fill_poly_color (Polygon *poly,
if (val > 0)
{
xx = (gdouble) j / (gdouble) SUPERSAMPLE + min_x;
alpha = (gint) (val * calc_alpha_blend (vec, one_over_dist, xx - sx, yy - sy));
alpha = (gint) (val * calc_alpha_blend (vec,
one_over_dist,
xx - sx,
yy - sy));
if (preview)
{
for (b = 0; b < bytes; b++)
@ -698,13 +695,13 @@ fill_poly_color (Polygon *poly,
#ifndef USE_READABLE_BUT_SLOW_CODE
{
guchar *buf_iter = buf,
*col_iter = col,
*buf_end = buf+bytes;
guchar *buf_iter = buf;
guchar *col_iter = col;
guchar *buf_end = buf + bytes;
for(; buf_iter < buf_end; buf_iter++, col_iter++)
*buf_iter = ((guint)(*col_iter * alpha)
+ (((guint)*buf_iter)
*buf_iter = ((guint) (*col_iter * alpha)
+ (((guint) *buf_iter)
* (256 - alpha))) >> 8;
}
#else /* original, pre-ECL code */

View File

@ -795,8 +795,7 @@ lcms_image_set_profile (gint32 image,
if (! file)
{
g_message (_("Could not open '%s' for reading: %s"),
gimp_filename_to_utf8 (filename), error->message);
g_message (error->message);
g_error_free (error);
return FALSE;
@ -948,7 +947,7 @@ lcms_image_transform_rgb (gint32 image,
break;
default:
g_warning ("%s: unexpected bpp", G_GNUC_FUNCTION);
g_warning ("%s: unexpected bpp", G_STRLOC);
continue;
}
@ -1100,9 +1099,7 @@ lcms_load_profile (const gchar *filename,
if (! file)
{
g_message (_("Could not open '%s' for reading: %s"),
gimp_filename_to_utf8 (filename),
error->message);
g_message (error->message);
g_error_free (error);
return NULL;
@ -1533,15 +1530,13 @@ lcms_dialog (GimpColorConfig *config,
&values->bpc);
}
run = (gimp_dialog_run (GIMP_DIALOG (dialog)) == GTK_RESPONSE_OK);
gtk_widget_hide (dialog);
if (run)
while ((run = gimp_dialog_run (GIMP_DIALOG (dialog))) == GTK_RESPONSE_OK)
{
gchar *filename = gimp_color_profile_combo_box_get_active (box);
cmsHPROFILE dest_profile;
gtk_widget_set_sensitive (dialog, FALSE);
if (filename)
{
dest_profile = lcms_load_profile (filename, NULL);
@ -1551,13 +1546,16 @@ lcms_dialog (GimpColorConfig *config,
dest_profile = cmsCreate_sRGBProfile ();
}
if (dest_profile)
{
if (lcms_icc_profile_is_rgb (dest_profile))
{
if (apply)
success = lcms_image_apply_profile (image,
src_profile, dest_profile,
filename,
values->intent, values->bpc);
values->intent,
values->bpc);
else
success = lcms_image_set_profile (image,
dest_profile, filename, TRUE);
@ -1570,6 +1568,12 @@ lcms_dialog (GimpColorConfig *config,
cmsCloseProfile (dest_profile);
}
if (success)
break;
else
gtk_widget_set_sensitive (dialog, TRUE);
}
gtk_widget_destroy (dialog);
cmsCloseProfile (src_profile);

View File

@ -977,8 +977,7 @@ load_image (const gchar *filename)
{
if (error)
{
g_message (_("Could not open '%s' for reading: %s"),
gimp_filename_to_utf8 (filename), error->message);
g_message (error->message);
g_error_free (error);
}
else

View File

@ -1,3 +1,20 @@
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "config.h"

View File

@ -1,3 +1,21 @@
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __BRUSH_H
#define __BRUSH_H

View File

@ -1,3 +1,21 @@
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <gtk/gtk.h>

View File

@ -1,3 +1,21 @@
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __COLOR_H
#define __COLOR_H

View File

@ -1,3 +1,21 @@
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <gtk/gtk.h>

View File

@ -1,3 +1,21 @@
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __GENERAL_H
#define __GENERAL_H

View File

@ -1,3 +1,21 @@
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <string.h>
@ -45,9 +63,7 @@ infile_copy_to_ppm (ppm_t * p)
{
if (!PPM_IS_INITED (&infile))
grabarea ();
#if 0
updatepreview (NULL, (void *)2); /* Force grabarea () */
#endif
ppm_copy (&infile, p);
}
@ -217,233 +233,248 @@ void
grabarea (void)
{
GimpPixelRgn src_rgn;
guchar *src_row;
guchar *src;
gint alpha, bpp;
gboolean has_alpha;
gint x, y;
ppm_t *p;
gint x1, y1, x2, y2;
gint x, y;
gint width, height;
gint row, col;
int rowstride;
gint rowstride;
gpointer pr;
gimp_drawable_mask_bounds (drawable->drawable_id, &x1, &y1, &x2, &y2);
bpp = gimp_drawable_bpp (drawable->drawable_id);
has_alpha = gimp_drawable_has_alpha (drawable->drawable_id);
alpha = (has_alpha) ? bpp - 1 : bpp;
width = x2 - x1;
height = y2 - y1;
ppm_new (&infile, x2-x1, y2-y1);
ppm_new (&infile, width, height);
p = &infile;
if (has_alpha)
{
ppm_new (&inalpha, x2-x1, y2-y1);
}
if (gimp_drawable_has_alpha (drawable->drawable_id))
ppm_new (&inalpha, width, height);
rowstride = p->width * 3;
src_row = g_new (guchar, (x2 - x1) * bpp);
gimp_pixel_rgn_init (&src_rgn,
drawable, x1, y1, width, height, FALSE, FALSE);
gimp_pixel_rgn_init (&src_rgn, drawable,
0, 0, x2 - x1, y2 - y1,
FALSE, FALSE);
if (bpp == 3)
{ /* RGB */
int bpr = (x2 - x1) * 3;
for (row = 0, y = y1; y < y2; row++, y++)
for (pr = gimp_pixel_rgns_register (1, &src_rgn);
pr != NULL;
pr = gimp_pixel_rgns_process (pr))
{
gimp_pixel_rgn_get_row (&src_rgn, src_row, x1, y, (x2 - x1));
memcpy (p->col + row * rowstride, src_row, bpr);
}
}
else if (bpp > 3)
{ /* RGBA */
for (row = 0, y = y1; y < y2; row++, y++)
const guchar *src = src_rgn.data;
switch (src_rgn.bpp)
{
case 1:
for (y = 0, row = src_rgn.y - y1; y < src_rgn.h; y++, row++)
{
const guchar *s = src;
guchar *tmprow = p->col + row * rowstride;
for (x = 0, col = src_rgn.x - x1; x < src_rgn.w; x++, col++)
{
gint k = col * 3;
tmprow[k + 0] = s[0];
tmprow[k + 1] = s[0];
tmprow[k + 2] = s[0];
s++;
}
src += src_rgn.rowstride;
}
break;
case 2:
for (y = 0, row = src_rgn.y - y1; y < src_rgn.h; y++, row++)
{
const guchar *s = src;
guchar *tmprow = p->col + row * rowstride;
guchar *tmparow = inalpha.col + row * rowstride;
gimp_pixel_rgn_get_row (&src_rgn, src_row, x1, y, (x2 - x1));
src = src_row;
for (x = 0, col = src_rgn.x - x1; x < src_rgn.w; x++, col++)
{
gint k = col * 3;
for (col = 0, x = x1; x < x2; col++, x++)
{
int k = col * 3;
tmprow[k + 0] = s[0];
tmprow[k + 1] = s[0];
tmprow[k + 2] = s[0];
tmparow[k] = 255 - s[1];
tmprow[k+0] = src[0];
tmprow[k+1] = src[1];
tmprow[k+2] = src[2];
tmparow[k] = 255 - src[3];
src += src_rgn.bpp;
s += 2;
}
src += src_rgn.rowstride;
}
}
else if (bpp == 2)
break;
case 3:
col = src_rgn.x - x1;
for (y = 0, row = src_rgn.y - y1; y < src_rgn.h; y++, row++)
{
/* GrayA */
for (row = 0, y = y1; y < y2; row++, y++)
memcpy (p->col + row * rowstride + col * 3, src, src_rgn.w * 3);
src += src_rgn.rowstride;
}
break;
case 4:
for (y = 0, row = src_rgn.y - y1; y < src_rgn.h; y++, row++)
{
const guchar *s = src;
guchar *tmprow = p->col + row * rowstride;
guchar *tmparow = inalpha.col + row * rowstride;
gimp_pixel_rgn_get_row (&src_rgn, src_row, x1, y, (x2 - x1));
src = src_row;
for (col = 0, x = x1; x < x2; col++, x++)
for (x = 0, col = src_rgn.x - x1; x < src_rgn.w; x++, col++)
{
int k = col * 3;
gint k = col * 3;
tmprow[k+0] = src[0];
tmprow[k+1] = src[0];
tmprow[k+2] = src[0];
tmparow[k] = 255 - src[1];
src += src_rgn.bpp;
}
}
}
else
{ /* Gray */
for (row = 0, y = y1; y < y2; row++, y++)
{
guchar *tmprow = p->col + row * rowstride;
tmprow[k + 0] = s[0];
tmprow[k + 1] = s[1];
tmprow[k + 2] = s[2];
tmparow[k] = 255 - s[3];
gimp_pixel_rgn_get_row (&src_rgn, src_row, x1, y, (x2 - x1));
src = src_row;
for (col = 0, x = x1; x < x2; col++, x++)
{
int k = col * 3;
s += 4;
}
tmprow[k+0] = src[0];
tmprow[k+1] = src[0];
tmprow[k+2] = src[0];
src += src_rgn.bpp;
src += src_rgn.rowstride;
}
break;
}
}
}
g_free (src_row);
}
static void
gimpressionist_main (void)
{
GimpPixelRgn dest_rgn;
guchar *dest_row;
guchar *dest;
gint alpha, bpp;
gboolean has_alpha;
gint x, y;
ppm_t *p;
gint x1, y1, x2, y2;
gint x, y;
gint width, height;
gint row, col;
int rowstride;
gint rowstride;
gint count;
glong done;
glong total;
gpointer pr;
gimp_drawable_mask_bounds (drawable->drawable_id, &x1, &y1, &x2, &y2);
bpp = gimp_drawable_bpp (drawable->drawable_id);
has_alpha = gimp_drawable_has_alpha (drawable->drawable_id);
alpha = (has_alpha) ? bpp - 1 : bpp;
width = x2 - x1;
height = y2 - y1;
dest_row = g_new (guchar, (x2 - x1) * bpp);
total = width * height;
gimp_progress_init (_("Painting"));
if (!PPM_IS_INITED (&infile))
{
if (! PPM_IS_INITED (&infile))
grabarea ();
}
repaint (&infile, (img_has_alpha) ? &inalpha : NULL);
gimp_pixel_rgn_init (&dest_rgn, drawable,
0, 0, x2 - x1, y2 - y1,
TRUE, TRUE);
p = &infile;
rowstride = p->width * 3;
if (bpp == 3)
{
int bpr = (x2 - x1) * 3;
gimp_pixel_rgn_init (&dest_rgn,
drawable, x1, y1, width, height, TRUE, TRUE);
for (row = 0, y = y1; y < y2; row++, y++)
{
if (row % 10 == 0)
gimp_progress_update (0.8 + 0.2 * ((double)row / (y2 - y1)));
memcpy (dest_row, p->col + row * rowstride, bpr);
gimp_pixel_rgn_set_row (&dest_rgn, dest_row, x1, y, (x2 - x1));
}
}
else if (bpp == 4)
for (pr = gimp_pixel_rgns_register (1, &dest_rgn), count = 0, done = 0;
pr != NULL;
pr = gimp_pixel_rgns_process (pr), count++)
{
guchar *dest = dest_rgn.data;
for (row = 0, y = y1; y < y2; row++, y++)
switch (dest_rgn.bpp)
{
guchar *tmprow = p->col + row * rowstride;
if (row % 10 == 0)
gimp_progress_update (0.8 + 0.2 * ((double)row / (y2-y1)));
dest = dest_row;
for (col = 0, x = x1; x < x2; col++, x++)
case 1:
for (y = 0, row = dest_rgn.y - y1; y < dest_rgn.h; y++, row++)
{
int k = col * 3;
guchar *d = dest;
const guchar *tmprow = p->col + row * rowstride;
dest[0] = tmprow[k+0];
dest[1] = tmprow[k+1];
dest[2] = tmprow[k+2];
dest[3] = 255 - inalpha.col[row * rowstride + k];
dest += dest_rgn.bpp;
}
gimp_pixel_rgn_set_row (&dest_rgn, dest_row, x1, y, (x2 - x1));
}
}
else if (bpp == 2)
for (x = 0, col = dest_rgn.x - x1; x < dest_rgn.w; x++, col++)
{
for (row = 0, y = y1; y < y2; row++, y++)
{
guchar *tmprow = p->col + row * rowstride;
gint k = col * 3;
if (row % 10 == 0)
gimp_progress_update (0.8 + 0.2 * ((double)row / (y2-y1)));
dest = dest_row;
for (col = 0, x = x1; x < x2; col++, x++)
{
int k = col * 3;
dest[0] = (tmprow[k+0] + tmprow[k+1] + tmprow[k+2]) / 3;
dest[1] = 255 - inalpha.col[row * rowstride + k];
dest += dest_rgn.bpp;
}
gimp_pixel_rgn_set_row (&dest_rgn, dest_row, x1, y, (x2 - x1));
}
}
else
{
for (row = 0, y = y1; y < y2; row++, y++)
{
guchar *tmprow = p->col + row * rowstride;
if (row % 10 == 0)
gimp_progress_update (0.8 + 0.2 * ((double)row / (y2-y1)));
dest = dest_row;
for (col = 0, x = x1; x < x2; col++, x++)
{
int k = col * 3;
dest[0] = (tmprow[k+0] + tmprow[k+1] + tmprow[k+2]) / 3;
dest += dest_rgn.bpp;
}
gimp_pixel_rgn_set_row (&dest_rgn, dest_row, x1, y, (x2 - x1));
}
*d++ = GIMP_RGB_LUMINANCE (tmprow[k + 0],
tmprow[k + 1],
tmprow[k + 2]);
}
g_free (dest_row);
dest += dest_rgn.rowstride;
}
break;
case 2:
for (y = 0, row = dest_rgn.y - y1; y < dest_rgn.h; y++, row++)
{
guchar *d = dest;
const guchar *tmprow = p->col + row * rowstride;
const guchar *tmparow = inalpha.col + row * rowstride;
for (x = 0, col = dest_rgn.x - x1; x < dest_rgn.w; x++, col++)
{
gint k = col * 3;
gint value = GIMP_RGB_LUMINANCE (tmprow[k + 0],
tmprow[k + 1],
tmprow[k + 2]);
d[0] = value;
d[1] = 255 - tmparow[k];
d += 2;
}
dest += dest_rgn.rowstride;
}
break;
case 3:
col = dest_rgn.x - x1;
for (y = 0, row = dest_rgn.y - y1; y < dest_rgn.h; y++, row++)
{
memcpy (dest, p->col + row * rowstride + col * 3, dest_rgn.w * 3);
dest += dest_rgn.rowstride;
}
break;
case 4:
for (y = 0, row = dest_rgn.y - y1; y < dest_rgn.h; y++, row++)
{
guchar *d = dest;
const guchar *tmprow = p->col + row * rowstride;
const guchar *tmparow = inalpha.col + row * rowstride;
for (x = 0, col = dest_rgn.x - x1; x < dest_rgn.w; x++, col++)
{
gint k = col * 3;
d[0] = tmprow[k + 0];
d[1] = tmprow[k + 1];
d[2] = tmprow[k + 2];
d[3] = 255 - tmparow[k];
d += 4;
}
dest += dest_rgn.rowstride;
}
break;
}
done += dest_rgn.w * dest_rgn.h;
if (count % 16 == 0)
gimp_progress_update (0.8 + 0.2 * done / total);
}
gimp_drawable_flush (drawable);
gimp_drawable_merge_shadow (drawable->drawable_id, TRUE);
gimp_drawable_update (drawable->drawable_id, x1, y1, (x2 - x1), (y2 - y1));
gimp_drawable_update (drawable->drawable_id, x1, y1, width, height);
}

View File

@ -1,3 +1,21 @@
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <libgimp/gimp.h>

View File

@ -1,3 +1,20 @@
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __GIMPRESSIONIST_H
#define __GIMPRESSIONIST_H

View File

@ -1,3 +1,21 @@
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <libgimp/gimp.h>

View File

@ -1,3 +1,21 @@
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __INFILE_H
#define __INFILE_H

View File

@ -1,3 +1,21 @@
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <gtk/gtk.h>

View File

@ -1,3 +1,21 @@
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __ORIENTATION_H
#define __ORIENTATION_H

View File

@ -1,3 +1,21 @@
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <gtk/gtk.h>

View File

@ -1,5 +1,24 @@
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __ORIENTMAP_H
#define __ORIENTMAP_H
void create_orientmap_dialog (GtkWidget *parent);
void update_orientmap_dialog (void);
void orientation_map_free_resources(void);

View File

@ -1,3 +1,21 @@
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <string.h>

View File

@ -1,3 +1,21 @@
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __PAPER_H
#define __PAPER_H

View File

@ -1,3 +1,21 @@
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <gtk/gtk.h>

View File

@ -1,3 +1,21 @@
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __PLACEMENT_H
#define __PLACEMENT_H

View File

@ -1,3 +1,21 @@
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <stdlib.h>

View File

@ -1,3 +1,21 @@
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <string.h>

View File

@ -1,3 +1,21 @@
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __PPM_TOOL_H
#define __PPM_TOOL_H

View File

@ -1,3 +1,21 @@
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <string.h>

View File

@ -1,3 +1,21 @@
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __PRESETS_H
#define __PRESETS_H

View File

@ -1,3 +1,21 @@
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <string.h>
@ -74,38 +92,6 @@ preview_free_resources (void)
void
updatepreview (GtkWidget *wg, gpointer d)
{
/* This portion is remmed out because of the remming out of the
* code below.
* -- Shlomi Fish
* */
#if 0
guchar buf[PREVIEWSIZE*3];
if (!PPM_IS_INITED (&infile) && d)
grabarea();
#endif
/* It seems that infile.col must be true here. (after grabarea() that is.)
* Thus, I'm removing this entire portion of the code in hope that
* it works OK afterwards.
* -- Shlomi Fish
* */
#if 0
if (!PPM_IS_INITED (&infile) && !d) {
guchar *buffer;
buffer = g_new0 (guchar, 3*PREVIEWSIZE*PREVIEWSIZE);
gimp_preview_area_draw (GIMP_PREVIEW_AREA (preview),
0, 0, PREVIEWSIZE, PREVIEWSIZE,
GIMP_RGB_IMAGE,
buffer,
PREVIEWSIZE * 3);
g_free (buffer);
}
else
#endif
{
if (!PPM_IS_INITED (&backup_ppm))
{
infile_copy_to_ppm (&backup_ppm);
@ -120,6 +106,7 @@ updatepreview (GtkWidget *wg, gpointer d)
resize_fast (&alpha_backup_ppm, PREVIEWSIZE, PREVIEWSIZE);
}
}
if (!PPM_IS_INITED (&preview_ppm))
{
ppm_copy (&backup_ppm, &preview_ppm);
@ -127,6 +114,7 @@ updatepreview (GtkWidget *wg, gpointer d)
if (img_has_alpha)
ppm_copy (&alpha_backup_ppm, &alpha_ppm);
}
if (d)
{
store_values ();
@ -134,6 +122,7 @@ updatepreview (GtkWidget *wg, gpointer d)
if (GPOINTER_TO_INT (d) != 2)
repaint (&preview_ppm, &alpha_ppm);
}
if (img_has_alpha)
drawalpha (&preview_ppm, &alpha_ppm);
@ -146,7 +135,6 @@ updatepreview (GtkWidget *wg, gpointer d)
ppm_kill (&preview_ppm);
if (img_has_alpha)
ppm_kill (&alpha_ppm);
}
}
static void

View File

@ -1,3 +1,21 @@
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __PREVIEW_H
#define __PREVIEW_H

View File

@ -1,3 +1,21 @@
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __RAND_H
#define __RAND_H

View File

@ -1,3 +1,21 @@
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <stdlib.h>

View File

@ -1,3 +1,21 @@
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <gtk/gtk.h>

View File

@ -1,3 +1,21 @@
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __SIZE_H
#define __SIZE_H

Some files were not shown because too many files have changed in this diff Show More