gimp r25726 - in trunk: . app/actions app/core app/dialogs app/gegl app/tools app/widgets libgimpwidgets menus po
- From: neo svn gnome org
- To: svn-commits-list gnome org
- Subject: gimp r25726 - in trunk: . app/actions app/core app/dialogs app/gegl app/tools app/widgets libgimpwidgets menus po
- Date: Wed, 21 May 2008 13:11:07 +0000 (UTC)
Author: neo
Date: Wed May 21 13:11:06 2008
New Revision: 25726
URL: http://svn.gnome.org/viewvc/gimp?rev=25726&view=rev
Log:
2008-05-21 Sven Neumann <sven gimp org>
Add Desaturate as an image-map tool with live preview (bug #533808):
* app/gegl/Makefile.am
* app/gegl/gegl-types.h
* app/gegl/gimpdesaturateconfig.[ch]: added config object for the
desaturate point filter.
* app/gegl/gimpoperationdesaturate.[ch]: derive from
GimpOperationPointFilter. Unrolled the inner loop.
* app/core/gimpdrawable-desaturate.c: changed accordingly.
* app/tools/Makefile.am
* app/tools/gimpdesaturatetool.[ch]: added desaturate as an
imagemap tool. So far only the GEGL code path is implemented.
* app/tools/gimp-tools.c: register the new tool.
* app/dialogs/dialogs.c: register the new tool dialog.
* app/dialogs/Makefile.am
* app/dialogs/desaturate-dialog.[ch]: removed the desaturate dialog.
* app/actions/drawable-actions.c
* app/actions/drawable-commands.[ch]: removed action
"drawable-desaturate".
* app/widgets/gimphelp-ids.h: changed help IDs accordingly.
* menus/image-menu.xml.in: replaced "drawable-desaturate" with
"tools-desaturate".
* libgimpwidgets/gimpstock.h: added a define for
GIMP_STOCK_TOOL_DESATURATE.
Added:
trunk/app/gegl/gimpdesaturateconfig.c (contents, props changed)
trunk/app/gegl/gimpdesaturateconfig.h (contents, props changed)
trunk/app/tools/gimpdesaturatetool.c (contents, props changed)
trunk/app/tools/gimpdesaturatetool.h (contents, props changed)
Removed:
trunk/app/dialogs/desaturate-dialog.c
trunk/app/dialogs/desaturate-dialog.h
Modified:
trunk/ChangeLog
trunk/app/actions/drawable-actions.c
trunk/app/actions/drawable-commands.c
trunk/app/actions/drawable-commands.h
trunk/app/core/gimpdrawable-desaturate.c
trunk/app/dialogs/Makefile.am
trunk/app/dialogs/dialogs.c
trunk/app/gegl/Makefile.am
trunk/app/gegl/gegl-types.h
trunk/app/gegl/gimpoperationdesaturate.c
trunk/app/gegl/gimpoperationdesaturate.h
trunk/app/tools/Makefile.am
trunk/app/tools/gimp-tools.c
trunk/app/widgets/gimphelp-ids.h
trunk/libgimpwidgets/gimpstock.h
trunk/menus/image-menu.xml.in
trunk/po/ChangeLog
trunk/po/POTFILES.in
Modified: trunk/app/actions/drawable-actions.c
==============================================================================
--- trunk/app/actions/drawable-actions.c (original)
+++ trunk/app/actions/drawable-actions.c Wed May 21 13:11:06 2008
@@ -41,12 +41,6 @@
static const GimpActionEntry drawable_actions[] =
{
- { "drawable-desaturate", GIMP_STOCK_CONVERT_GRAYSCALE,
- N_("_Desaturate..."), NULL,
- N_("Turn colors into shades of gray"),
- G_CALLBACK (drawable_desaturate_cmd_callback),
- GIMP_HELP_LAYER_DESATURATE },
-
{ "drawable-equalize", NULL,
N_("_Equalize"), NULL,
N_("Automatic contrast enhancement"),
@@ -190,7 +184,6 @@
#define SET_ACTIVE(action,condition) \
gimp_action_group_set_action_active (group, action, (condition) != 0)
- SET_SENSITIVE ("drawable-desaturate", drawable && is_rgb);
SET_SENSITIVE ("drawable-equalize", drawable && ! is_indexed);
SET_SENSITIVE ("drawable-invert", drawable && ! is_indexed);
SET_SENSITIVE ("drawable-levels-stretch", drawable && is_rgb);
Modified: trunk/app/actions/drawable-commands.c
==============================================================================
--- trunk/app/actions/drawable-commands.c (original)
+++ trunk/app/actions/drawable-commands.c Wed May 21 13:11:06 2008
@@ -36,7 +36,6 @@
#include "core/gimplayermask.h"
#include "core/gimpprogress.h"
-#include "dialogs/desaturate-dialog.h"
#include "dialogs/offset-dialog.h"
#include "actions.h"
@@ -45,50 +44,9 @@
#include "gimp-intl.h"
-/* local function prototypes */
-
-static void desaturate_response (GtkWidget *widget,
- gint response_id,
- DesaturateDialog *dialog);
-
-
-/* private variables */
-
-static GimpDesaturateMode desaturate_mode = GIMP_DESATURATE_LIGHTNESS;
-
-
/* public functions */
void
-drawable_desaturate_cmd_callback (GtkAction *action,
- gpointer data)
-{
- DesaturateDialog *dialog;
- GimpImage *image;
- GimpDrawable *drawable;
- GtkWidget *widget;
- return_if_no_drawable (image, drawable, data);
- return_if_no_widget (widget, data);
-
- if (! gimp_drawable_is_rgb (drawable))
- {
- gimp_message (image->gimp, G_OBJECT (widget), GIMP_MESSAGE_WARNING,
- _("Desaturate operates only on RGB color layers."));
- return;
- }
-
- dialog = desaturate_dialog_new (drawable,
- action_data_get_context (data),
- widget, desaturate_mode);
-
- g_signal_connect (dialog->dialog, "response",
- G_CALLBACK (desaturate_response),
- dialog);
-
- gtk_widget_show (dialog->dialog);
-}
-
-void
drawable_equalize_cmd_callback (GtkAction *action,
gpointer data)
{
@@ -325,26 +283,3 @@
gimp_image_flush (image);
}
-
-/* private functions */
-
-static void
-desaturate_response (GtkWidget *widget,
- gint response_id,
- DesaturateDialog *dialog)
-{
- if (response_id == GTK_RESPONSE_OK)
- {
- GimpDrawable *drawable = dialog->drawable;
- GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
-
- /* remember for next invocation of the dialog */
- desaturate_mode = dialog->mode;
-
- gimp_drawable_desaturate (drawable, desaturate_mode);
-
- gimp_image_flush (image);
- }
-
- gtk_widget_destroy (dialog->dialog);
-}
Modified: trunk/app/actions/drawable-commands.h
==============================================================================
--- trunk/app/actions/drawable-commands.h (original)
+++ trunk/app/actions/drawable-commands.h Wed May 21 13:11:06 2008
@@ -20,8 +20,6 @@
#define __DRAWABLE_COMMANDS_H__
-void drawable_desaturate_cmd_callback (GtkAction *action,
- gpointer data);
void drawable_equalize_cmd_callback (GtkAction *action,
gpointer data);
void drawable_invert_cmd_callback (GtkAction *action,
@@ -43,4 +41,5 @@
gint value,
gpointer data);
+
#endif /* __DRAWABLE_COMMANDS_H__ */
Modified: trunk/app/core/gimpdrawable-desaturate.c
==============================================================================
--- trunk/app/core/gimpdrawable-desaturate.c (original)
+++ trunk/app/core/gimpdrawable-desaturate.c Wed May 21 13:11:06 2008
@@ -27,6 +27,8 @@
#include "base/pixel-processor.h"
#include "base/pixel-region.h"
+#include "gegl/gimpdesaturateconfig.h"
+
/* temp */
#include "gimp.h"
#include "gimpimage.h"
@@ -63,15 +65,22 @@
if (gimp_use_gegl (GIMP_ITEM (drawable)->image->gimp))
{
GeglNode *desaturate;
+ GObject *config;
desaturate = g_object_new (GEGL_TYPE_NODE,
"operation", "gimp-desaturate",
NULL);
+ config = g_object_new (GIMP_TYPE_DESATURATE_CONFIG,
+ "mode", mode,
+ NULL);
+
gegl_node_set (desaturate,
- "mode", mode,
+ "config", config,
NULL);
+ g_object_unref (config);
+
gimp_drawable_apply_operation (drawable, desaturate, TRUE,
NULL, _("Desaturate"));
Modified: trunk/app/dialogs/Makefile.am
==============================================================================
--- trunk/app/dialogs/Makefile.am (original)
+++ trunk/app/dialogs/Makefile.am Wed May 21 13:11:06 2008
@@ -26,8 +26,6 @@
channel-options-dialog.h \
convert-dialog.c \
convert-dialog.h \
- desaturate-dialog.c \
- desaturate-dialog.h \
fade-dialog.c \
fade-dialog.h \
file-open-dialog.c \
Modified: trunk/app/dialogs/dialogs.c
==============================================================================
--- trunk/app/dialogs/dialogs.c (original)
+++ trunk/app/dialogs/dialogs.c Wed May 21 13:11:06 2008
@@ -49,11 +49,11 @@
GimpContainer *global_recent_docks = NULL;
-#define FOREIGN(id,singleton,remember_size) \
+#define FOREIGN(id, singleton, remember_size) \
{ id, NULL, NULL, NULL, NULL, \
NULL, 0, singleton, TRUE, remember_size, FALSE }
-#define TOPLEVEL(id,new_func,singleton,session_managed,remember_size) \
+#define TOPLEVEL(id, new_func, singleton, session_managed, remember_size) \
{ id, NULL, NULL, NULL, NULL, \
new_func, 0, singleton, session_managed, remember_size, FALSE }
@@ -62,11 +62,12 @@
{
/* foreign toplevels without constructor */
FOREIGN ("gimp-brightness-contrast-tool-dialog", TRUE, FALSE),
+ FOREIGN ("gimp-color-balance-tool-dialog", TRUE, FALSE),
FOREIGN ("gimp-color-picker-tool-dialog", TRUE, TRUE),
FOREIGN ("gimp-colorize-tool-dialog", TRUE, FALSE),
FOREIGN ("gimp-crop-tool-dialog", TRUE, FALSE),
FOREIGN ("gimp-curves-tool-dialog", TRUE, TRUE),
- FOREIGN ("gimp-color-balance-tool-dialog", TRUE, FALSE),
+ FOREIGN ("gimp-desaturate-tool-dialog", TRUE, FALSE),
FOREIGN ("gimp-gegl-tool-dialog", TRUE, FALSE),
FOREIGN ("gimp-hue-saturation-tool-dialog", TRUE, FALSE),
FOREIGN ("gimp-levels-tool-dialog", TRUE, TRUE),
Modified: trunk/app/gegl/Makefile.am
==============================================================================
--- trunk/app/gegl/Makefile.am (original)
+++ trunk/app/gegl/Makefile.am Wed May 21 13:11:06 2008
@@ -17,6 +17,8 @@
gimpcolorizeconfig.h \
gimpcurvesconfig.c \
gimpcurvesconfig.h \
+ gimpdesaturateconfig.c \
+ gimpdesaturateconfig.h \
gimphuesaturationconfig.c \
gimphuesaturationconfig.h \
gimplevelsconfig.c \
Modified: trunk/app/gegl/gegl-types.h
==============================================================================
--- trunk/app/gegl/gegl-types.h (original)
+++ trunk/app/gegl/gegl-types.h Wed May 21 13:11:06 2008
@@ -47,6 +47,7 @@
typedef struct _GimpColorBalanceConfig GimpColorBalanceConfig;
typedef struct _GimpColorizeConfig GimpColorizeConfig;
typedef struct _GimpCurvesConfig GimpCurvesConfig;
+typedef struct _GimpDesaturateConfig GimpDesaturateConfig;
typedef struct _GimpHueSaturationConfig GimpHueSaturationConfig;
typedef struct _GimpLevelsConfig GimpLevelsConfig;
typedef struct _GimpPosterizeConfig GimpPosterizeConfig;
Added: trunk/app/gegl/gimpdesaturateconfig.c
==============================================================================
--- (empty file)
+++ trunk/app/gegl/gimpdesaturateconfig.c Wed May 21 13:11:06 2008
@@ -0,0 +1,118 @@
+/* GIMP - The GNU Image Manipulation Program
+ * Copyright (C) 1995 Spencer Kimball and Peter Mattis
+ *
+ * gimpdesaturateconfig.c
+ * Copyright (C) 2008 Sven Neumann <sven 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 "gimpdesaturateconfig.h"
+
+
+enum
+{
+ PROP_0,
+ PROP_MODE
+};
+
+
+static void gimp_desaturate_config_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec);
+static void gimp_desaturate_config_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec);
+
+
+G_DEFINE_TYPE_WITH_CODE (GimpDesaturateConfig, gimp_desaturate_config,
+ GIMP_TYPE_IMAGE_MAP_CONFIG,
+ G_IMPLEMENT_INTERFACE (GIMP_TYPE_CONFIG, NULL))
+
+#define parent_class gimp_desaturate_config_parent_class
+
+
+static void
+gimp_desaturate_config_class_init (GimpDesaturateConfigClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GimpViewableClass *viewable_class = GIMP_VIEWABLE_CLASS (klass);
+
+ object_class->set_property = gimp_desaturate_config_set_property;
+ object_class->get_property = gimp_desaturate_config_get_property;
+
+ viewable_class->default_stock_id = "gimp-tool-desaturate";
+
+ GIMP_CONFIG_INSTALL_PROP_ENUM (object_class, PROP_MODE,
+ "mode",
+ "Desaturate mode",
+ GIMP_TYPE_DESATURATE_MODE,
+ GIMP_DESATURATE_LIGHTNESS, 0);
+}
+
+static void
+gimp_desaturate_config_init (GimpDesaturateConfig *self)
+{
+}
+
+static void
+gimp_desaturate_config_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GimpDesaturateConfig *self = GIMP_DESATURATE_CONFIG (object);
+
+ switch (property_id)
+ {
+ case PROP_MODE:
+ g_value_set_enum (value, self->mode);
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+static void
+gimp_desaturate_config_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GimpDesaturateConfig *self = GIMP_DESATURATE_CONFIG (object);
+
+ switch (property_id)
+ {
+ case PROP_MODE:
+ self->mode = g_value_get_enum (value);
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
Added: trunk/app/gegl/gimpdesaturateconfig.h
==============================================================================
--- (empty file)
+++ trunk/app/gegl/gimpdesaturateconfig.h Wed May 21 13:11:06 2008
@@ -0,0 +1,55 @@
+/* GIMP - The GNU Image Manipulation Program
+ * Copyright (C) 1995 Spencer Kimball and Peter Mattis
+ *
+ * gimpdesaturateconfig.h
+ * Copyright (C) 2008 Sven Neumann <sven 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_DESATURATE_CONFIG_H__
+#define __GIMP_DESATURATE_CONFIG_H__
+
+
+#include "core/gimpimagemapconfig.h"
+
+
+#define GIMP_TYPE_DESATURATE_CONFIG (gimp_desaturate_config_get_type ())
+#define GIMP_DESATURATE_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_DESATURATE_CONFIG, GimpDesaturateConfig))
+#define GIMP_DESATURATE_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_DESATURATE_CONFIG, GimpDesaturateConfigClass))
+#define GIMP_IS_DESATURATE_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_DESATURATE_CONFIG))
+#define GIMP_IS_DESATURATE_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_DESATURATE_CONFIG))
+#define GIMP_DESATURATE_CONFIG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_DESATURATE_CONFIG, GimpDesaturateConfigClass))
+
+
+typedef struct _GimpDesaturateConfigClass GimpDesaturateConfigClass;
+
+struct _GimpDesaturateConfig
+{
+ GimpImageMapConfig parent_instance;
+
+ GimpDesaturateMode mode;
+};
+
+struct _GimpDesaturateConfigClass
+{
+ GimpImageMapConfigClass parent_class;
+};
+
+
+GType gimp_desaturate_config_get_type (void) G_GNUC_CONST;
+
+
+#endif /* __GIMP_DESATURATE_CONFIG_H__ */
Modified: trunk/app/gegl/gimpoperationdesaturate.c
==============================================================================
--- trunk/app/gegl/gimpoperationdesaturate.c (original)
+++ trunk/app/gegl/gimpoperationdesaturate.c Wed May 21 13:11:06 2008
@@ -28,32 +28,17 @@
#include "gegl-types.h"
#include "gimpoperationdesaturate.h"
+#include "gimpdesaturateconfig.h"
-enum
-{
- PROP_0,
- PROP_MODE
-};
-
-
-static void gimp_operation_desaturate_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec);
-static void gimp_operation_desaturate_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec);
-
-static gboolean gimp_operation_desaturate_process (GeglOperation *operation,
- void *in_buf,
- void *out_buf,
- glong samples);
+static gboolean gimp_operation_desaturate_process (GeglOperation *operation,
+ void *in_buf,
+ void *out_buf,
+ glong samples);
G_DEFINE_TYPE (GimpOperationDesaturate, gimp_operation_desaturate,
- GEGL_TYPE_OPERATION_POINT_FILTER)
+ GIMP_TYPE_OPERATION_POINT_FILTER)
#define parent_class gimp_operation_desaturate_parent_class
@@ -65,8 +50,8 @@
GeglOperationClass *operation_class = GEGL_OPERATION_CLASS (klass);
GeglOperationPointFilterClass *point_class = GEGL_OPERATION_POINT_FILTER_CLASS (klass);
- object_class->set_property = gimp_operation_desaturate_set_property;
- object_class->get_property = gimp_operation_desaturate_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-desaturate";
operation_class->categories = "color";
@@ -75,14 +60,13 @@
point_class->process = gimp_operation_desaturate_process;
g_object_class_install_property (object_class,
- PROP_MODE,
- g_param_spec_enum ("mode",
- "Mode",
- "The desaturate mode",
- GIMP_TYPE_DESATURATE_MODE,
- GIMP_DESATURATE_LIGHTNESS,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT));
+ GIMP_OPERATION_POINT_FILTER_PROP_CONFIG,
+ g_param_spec_object ("config",
+ "Config",
+ "The config object",
+ GIMP_TYPE_DESATURATE_CONFIG,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT));
}
static void
@@ -90,97 +74,70 @@
{
}
-static void
-gimp_operation_desaturate_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec)
-{
- GimpOperationDesaturate *self = GIMP_OPERATION_DESATURATE (object);
-
- switch (property_id)
- {
- case PROP_MODE:
- g_value_set_enum (value, self->mode);
- break;
-
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
- break;
- }
-}
-
-static void
-gimp_operation_desaturate_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- GimpOperationDesaturate *self = GIMP_OPERATION_DESATURATE (object);
-
- switch (property_id)
- {
- case PROP_MODE:
- self->mode = g_value_get_enum (value);
- break;
-
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
- break;
- }
-}
-
static gboolean
gimp_operation_desaturate_process (GeglOperation *operation,
void *in_buf,
void *out_buf,
glong samples)
{
- GimpOperationDesaturate *self = GIMP_OPERATION_DESATURATE (operation);
- gfloat *src = in_buf;
- gfloat *dest = out_buf;
+ GimpOperationPointFilter *point = GIMP_OPERATION_POINT_FILTER (operation);
+ GimpDesaturateConfig *config = GIMP_DESATURATE_CONFIG (point->config);
+ gfloat *src = in_buf;
+ gfloat *dest = out_buf;
- while (samples--)
+ switch (config->mode)
{
- gfloat value = 0.0;
+ case GIMP_DESATURATE_LIGHTNESS:
+ while (samples--)
+ {
+ gfloat min, max, value;
+
+ max = MAX (src[0], src[1]);
+ max = MAX (max, src[2]);
+ min = MIN (src[0], src[1]);
+ min = MIN (min, src[2]);
+
+ value = (max + min) / 2;
+
+ dest[0] = value;
+ dest[1] = value;
+ dest[2] = value;
+ dest[3] = src[3];
+
+ src += 4;
+ dest += 4;
+ }
+ break;
- switch (self->mode)
+ case GIMP_DESATURATE_LUMINOSITY:
+ while (samples--)
{
- case GIMP_DESATURATE_LIGHTNESS:
- {
- gfloat min, max;
-
-#ifdef __GNUC__
-#warning FIXME: cant use FOO_PIX but have no constants from babl???
-#endif
-
- max = MAX (src[RED_PIX], src[GREEN_PIX]);
- max = MAX (max, src[BLUE_PIX]);
- min = MIN (src[RED_PIX], src[GREEN_PIX]);
- min = MIN (min, src[BLUE_PIX]);
-
- value = (max + min) / 2;
- }
- break;
-
- case GIMP_DESATURATE_LUMINOSITY:
- value = GIMP_RGB_LUMINANCE (src[RED_PIX],
- src[GREEN_PIX],
- src[BLUE_PIX]);
- break;
-
- case GIMP_DESATURATE_AVERAGE:
- value = (src[RED_PIX] + src[GREEN_PIX] + src[BLUE_PIX]) / 3;
- break;
+ gfloat value = GIMP_RGB_LUMINANCE (src[0], src[1], src[2]);
+
+ dest[0] = value;
+ dest[1] = value;
+ dest[2] = value;
+ dest[3] = src[3];
+
+ src += 4;
+ dest += 4;
}
+ break;
- dest[RED_PIX] = value;
- dest[GREEN_PIX] = value;
- dest[BLUE_PIX] = value;
- dest[ALPHA_PIX] = src[ALPHA_PIX];
+ case GIMP_DESATURATE_AVERAGE:
+ while (samples--)
+ {
+ gfloat value = (src[0] + src[1] + src[2]) / 3;
+
+ dest[0] = value;
+ dest[1] = value;
+ dest[2] = value;
+ dest[3] = src[3];
- src += 4;
- dest += 4;
+ src += 4;
+ dest += 4;
+ }
+ break;
}
return TRUE;
Modified: trunk/app/gegl/gimpoperationdesaturate.h
==============================================================================
--- trunk/app/gegl/gimpoperationdesaturate.h (original)
+++ trunk/app/gegl/gimpoperationdesaturate.h Wed May 21 13:11:06 2008
@@ -22,8 +22,8 @@
#ifndef __GIMP_OPERATION_DESATURATE_H__
#define __GIMP_OPERATION_DESATURATE_H__
-#include <gegl-plugin.h>
-#include <operation/gegl-operation-point-filter.h>
+
+#include "gimpoperationpointfilter.h"
#define GIMP_TYPE_OPERATION_DESATURATE (gimp_operation_desaturate_get_type ())
@@ -36,14 +36,12 @@
struct _GimpOperationDesaturate
{
- GeglOperationPointFilter parent_instance;
-
- GimpDesaturateMode mode;
+ GimpOperationPointFilter parent_instance;
};
struct _GimpOperationDesaturateClass
{
- GeglOperationPointFilterClass parent_class;
+ GimpOperationPointFilterClass parent_class;
};
Modified: trunk/app/tools/Makefile.am
==============================================================================
--- trunk/app/tools/Makefile.am (original)
+++ trunk/app/tools/Makefile.am Wed May 21 13:11:06 2008
@@ -54,6 +54,8 @@
gimpcroptool.h \
gimpcurvestool.c \
gimpcurvestool.h \
+ gimpdesaturatetool.c \
+ gimpdesaturatetool.h \
gimpdodgeburntool.c \
gimpdodgeburntool.h \
gimpdrawtool.c \
Modified: trunk/app/tools/gimp-tools.c
==============================================================================
--- trunk/app/tools/gimp-tools.c (original)
+++ trunk/app/tools/gimp-tools.c Wed May 21 13:11:06 2008
@@ -50,6 +50,7 @@
#include "gimpconvolvetool.h"
#include "gimpcroptool.h"
#include "gimpcurvestool.h"
+#include "gimpdesaturatetool.h"
#include "gimpdodgeburntool.h"
#include "gimpellipseselecttool.h"
#include "gimperasertool.h"
@@ -125,6 +126,7 @@
gimp_colorize_tool_register,
gimp_hue_saturation_tool_register,
gimp_color_balance_tool_register,
+ gimp_desaturate_tool_register,
/* paint tools */
Added: trunk/app/tools/gimpdesaturatetool.c
==============================================================================
--- (empty file)
+++ trunk/app/tools/gimpdesaturatetool.c Wed May 21 13:11:06 2008
@@ -0,0 +1,229 @@
+/* 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 <gegl.h>
+#include <gtk/gtk.h>
+
+#include "libgimpmath/gimpmath.h"
+#include "libgimpconfig/gimpconfig.h"
+#include "libgimpwidgets/gimpwidgets.h"
+
+#include "tools-types.h"
+
+#include "base/gimplut.h"
+#include "base/lut-funcs.h"
+
+#include "gegl/gimpdesaturateconfig.h"
+
+#include "core/gimpdrawable.h"
+#include "core/gimpimage.h"
+
+#include "widgets/gimphelp-ids.h"
+
+#include "display/gimpdisplay.h"
+
+#include "gimpimagemapoptions.h"
+#include "gimpdesaturatetool.h"
+
+#include "gimp-intl.h"
+
+
+static gboolean gimp_desaturate_tool_initialize (GimpTool *tool,
+ GimpDisplay *display,
+ GError **error);
+
+static GeglNode * gimp_desaturate_tool_get_operation (GimpImageMapTool *im_tool,
+ GObject **config);
+static void gimp_desaturate_tool_map (GimpImageMapTool *im_tool);
+static void gimp_desaturate_tool_dialog (GimpImageMapTool *im_tool);
+
+static void gimp_desaturate_tool_config_notify (GObject *object,
+ GParamSpec *pspec,
+ GimpDesaturateTool *desaturate_tool);
+static void gimp_desaturate_tool_mode_changed (GtkWidget *button,
+ GimpDesaturateTool *desaturate_tool);
+
+
+G_DEFINE_TYPE (GimpDesaturateTool, gimp_desaturate_tool,
+ GIMP_TYPE_IMAGE_MAP_TOOL)
+
+#define parent_class gimp_desaturate_tool_parent_class
+
+
+void
+gimp_desaturate_tool_register (GimpToolRegisterCallback callback,
+ gpointer data)
+{
+ (* callback) (GIMP_TYPE_DESATURATE_TOOL,
+ GIMP_TYPE_IMAGE_MAP_OPTIONS, NULL,
+ 0,
+ "gimp-desaturate-tool",
+ _("Desaturate"),
+ _("Desaturate Tool: Turn colors into shades of gray"),
+ N_("_Desaturate..."), NULL,
+ NULL, GIMP_HELP_TOOL_DESATURATE,
+ GIMP_STOCK_TOOL_DESATURATE,
+ data);
+}
+
+static void
+gimp_desaturate_tool_class_init (GimpDesaturateToolClass *klass)
+{
+ GimpToolClass *tool_class = GIMP_TOOL_CLASS (klass);
+ GimpImageMapToolClass *im_tool_class = GIMP_IMAGE_MAP_TOOL_CLASS (klass);
+
+ tool_class->initialize = gimp_desaturate_tool_initialize;
+
+ im_tool_class->shell_desc = _("Desaturate (Remove Colors)");
+ im_tool_class->settings_name = "desaturate";
+ im_tool_class->load_dialog_title = _("Load Desaturate Settings");
+ im_tool_class->load_button_tip = _("Load desaturate settings from file");
+ im_tool_class->save_dialog_title = _("Save Desaturate Settings");
+ im_tool_class->save_button_tip = _("Save desaturate settings to file");
+
+ im_tool_class->get_operation = gimp_desaturate_tool_get_operation;
+ im_tool_class->map = gimp_desaturate_tool_map;
+ im_tool_class->dialog = gimp_desaturate_tool_dialog;
+}
+
+static void
+gimp_desaturate_tool_init (GimpDesaturateTool *desaturate_tool)
+{
+}
+
+static gboolean
+gimp_desaturate_tool_initialize (GimpTool *tool,
+ GimpDisplay *display,
+ GError **error)
+{
+ GimpDesaturateTool *desaturate_tool = GIMP_DESATURATE_TOOL (tool);
+ GimpDrawable *drawable;
+
+ drawable = gimp_image_get_active_drawable (display->image);
+
+ if (! drawable)
+ return FALSE;
+
+ if (! gimp_drawable_is_rgb (drawable))
+ {
+ g_set_error (error, 0, 0,
+ _("Desaturate does only operate on RGB layers."));
+ return FALSE;
+ }
+
+ gimp_config_reset (GIMP_CONFIG (desaturate_tool->config));
+
+ GIMP_TOOL_CLASS (parent_class)->initialize (tool, display, error);
+
+ gimp_int_radio_group_set_active (GTK_RADIO_BUTTON (desaturate_tool->button),
+ desaturate_tool->config->mode);
+
+ gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (desaturate_tool));
+
+ return TRUE;
+}
+
+static GeglNode *
+gimp_desaturate_tool_get_operation (GimpImageMapTool *image_map_tool,
+ GObject **config)
+{
+ GimpDesaturateTool *desaturate_tool = GIMP_DESATURATE_TOOL (image_map_tool);
+ GeglNode *node;
+
+ node = g_object_new (GEGL_TYPE_NODE,
+ "operation", "gimp-desaturate",
+ NULL);
+
+ desaturate_tool->config = g_object_new (GIMP_TYPE_DESATURATE_CONFIG, NULL);
+
+ *config = G_OBJECT (desaturate_tool->config);
+
+ g_signal_connect_object (desaturate_tool->config, "notify",
+ G_CALLBACK (gimp_desaturate_tool_config_notify),
+ G_OBJECT (desaturate_tool), 0);
+
+ gegl_node_set (node,
+ "config", desaturate_tool->config,
+ NULL);
+
+ return node;
+}
+
+static void
+gimp_desaturate_tool_map (GimpImageMapTool *image_map_tool)
+{
+}
+
+
+/**********************/
+/* Desaturate dialog */
+/**********************/
+
+static void
+gimp_desaturate_tool_dialog (GimpImageMapTool *image_map_tool)
+{
+ GimpDesaturateTool *desaturate_tool = GIMP_DESATURATE_TOOL (image_map_tool);
+ GtkWidget *frame;
+
+ /* The table containing sliders */
+ frame = gimp_enum_radio_frame_new (GIMP_TYPE_DESATURATE_MODE,
+ gtk_label_new (_("Choose shade of gray based on:")),
+ G_CALLBACK (gimp_desaturate_tool_mode_changed),
+ desaturate_tool,
+ &desaturate_tool->button);
+
+ gtk_box_pack_start (GTK_BOX (image_map_tool->main_vbox), frame,
+ FALSE, FALSE, 0);
+ gtk_widget_show (frame);
+}
+
+static void
+gimp_desaturate_tool_config_notify (GObject *object,
+ GParamSpec *pspec,
+ GimpDesaturateTool *desaturate_tool)
+{
+ GimpDesaturateConfig *config = GIMP_DESATURATE_CONFIG (object);
+
+ if (! desaturate_tool->button)
+ return;
+
+ gimp_int_radio_group_set_active (GTK_RADIO_BUTTON (desaturate_tool->button),
+ config->mode);
+
+ gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (desaturate_tool));
+}
+
+static void
+gimp_desaturate_tool_mode_changed (GtkWidget *button,
+ GimpDesaturateTool *desaturate_tool)
+{
+ GimpDesaturateConfig *config = desaturate_tool->config;
+ GimpDesaturateMode mode;
+
+ mode = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (button),
+ "gimp-item-data"));
+
+ if (config->mode != mode)
+ {
+ g_object_set (config,
+ "mode", mode,
+ NULL);
+ }
+}
Added: trunk/app/tools/gimpdesaturatetool.h
==============================================================================
--- (empty file)
+++ trunk/app/tools/gimpdesaturatetool.h Wed May 21 13:11:06 2008
@@ -0,0 +1,59 @@
+/* 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 __GIMP_DESATURATE_TOOL_H__
+#define __GIMP_DESATURATE_TOOL_H__
+
+
+#include "gimpimagemaptool.h"
+
+
+#define GIMP_TYPE_DESATURATE_TOOL (gimp_desaturate_tool_get_type ())
+#define GIMP_DESATURATE_TOOL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_DESATURATE_TOOL, GimpDesaturateTool))
+#define GIMP_DESATURATE_TOOL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_DESATURATE_TOOL, GimpDesaturateToolClass))
+#define GIMP_IS_DESATURATE_TOOL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_DESATURATE_TOOL))
+#define GIMP_IS_DESATURATE_TOOL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_DESATURATE_TOOL))
+#define GIMP_DESATURATE_TOOL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_DESATURATE_TOOL, GimpDesaturateToolClass))
+
+
+typedef struct _GimpDesaturateTool GimpDesaturateTool;
+typedef struct _GimpDesaturateToolClass GimpDesaturateToolClass;
+
+struct _GimpDesaturateTool
+{
+ GimpImageMapTool parent_instance;
+
+ GimpDesaturateConfig *config;
+
+ /* dialog */
+ GtkWidget *button;
+};
+
+struct _GimpDesaturateToolClass
+{
+ GimpImageMapToolClass parent_class;
+};
+
+
+void gimp_desaturate_tool_register (GimpToolRegisterCallback callback,
+ gpointer data);
+
+GType gimp_desaturate_tool_get_type (void) G_GNUC_CONST;
+
+
+#endif /* __GIMP_DESATURATE_TOOL_H__ */
Modified: trunk/app/widgets/gimphelp-ids.h
==============================================================================
--- trunk/app/widgets/gimphelp-ids.h (original)
+++ trunk/app/widgets/gimphelp-ids.h Wed May 21 13:11:06 2008
@@ -155,7 +155,6 @@
#define GIMP_HELP_LAYER_RAISE_TO_TOP "gimp-layer-raise-to-top"
#define GIMP_HELP_LAYER_LOWER "gimp-layer-lower"
#define GIMP_HELP_LAYER_LOWER_TO_BOTTOM "gimp-layer-lower-to-bottom"
-#define GIMP_HELP_LAYER_DESATURATE "gimp-layer-desaturate"
#define GIMP_HELP_LAYER_INVERT "gimp-layer-invert"
#define GIMP_HELP_LAYER_WHITE_BALANCE "gimp-layer-white-balance"
#define GIMP_HELP_LAYER_EQUALIZE "gimp-layer-equalize"
@@ -248,6 +247,7 @@
#define GIMP_HELP_TOOL_CROP "gimp-tool-crop"
#define GIMP_HELP_TOOL_CURVES "gimp-tool-curves"
#define GIMP_HELP_TOOL_CURVES "gimp-tool-curves"
+#define GIMP_HELP_TOOL_DESATURATE "gimp-tool-desaturate"
#define GIMP_HELP_TOOL_DODGE_BURN "gimp-tool-dodge-burn"
#define GIMP_HELP_TOOL_ELLIPSE_SELECT "gimp-tool-ellipse-select"
#define GIMP_HELP_TOOL_ERASER "gimp-tool-eraser"
Modified: trunk/libgimpwidgets/gimpstock.h
==============================================================================
--- trunk/libgimpwidgets/gimpstock.h (original)
+++ trunk/libgimpwidgets/gimpstock.h Wed May 21 13:11:06 2008
@@ -275,6 +275,7 @@
#define GIMP_STOCK_GRADIENT GIMP_STOCK_TOOL_BLEND
#define GIMP_STOCK_PALETTE GTK_STOCK_SELECT_COLOR
#define GIMP_STOCK_PATTERN GIMP_STOCK_TOOL_BUCKET_FILL
+#define GIMP_STOCK_TOOL_DESATURATE GIMP_STOCK_CONVERT_GRAYSCALE
void gimp_stock_init (void);
Modified: trunk/menus/image-menu.xml.in
==============================================================================
--- trunk/menus/image-menu.xml.in (original)
+++ trunk/menus/image-menu.xml.in Wed May 21 13:11:06 2008
@@ -479,7 +479,7 @@
<menuitem action="tools-curves" />
<menuitem action="tools-posterize" />
<separator />
- <menuitem action="drawable-desaturate" />
+ <menuitem action="tools-desaturate" />
<placeholder name="Invert">
<menuitem action="drawable-invert" />
</placeholder>
Modified: trunk/po/POTFILES.in
==============================================================================
--- trunk/po/POTFILES.in (original)
+++ trunk/po/POTFILES.in Wed May 21 13:11:06 2008
@@ -164,7 +164,6 @@
app/dialogs/about-dialog.c
app/dialogs/channel-options-dialog.c
app/dialogs/convert-dialog.c
-app/dialogs/desaturate-dialog.c
app/dialogs/dialogs-constructors.c
app/dialogs/dialogs.c
app/dialogs/fade-dialog.c
@@ -306,6 +305,7 @@
app/tools/gimpcropoptions.c
app/tools/gimpcroptool.c
app/tools/gimpcurvestool.c
+app/tools/gimpdesaturatetool.c
app/tools/gimpdodgeburntool.c
app/tools/gimpeditselectiontool.c
app/tools/gimpellipseselecttool.c
@@ -320,6 +320,7 @@
app/tools/gimphealtool.c
app/tools/gimphistogramoptions.c
app/tools/gimphuesaturationtool.c
+app/tools/gimpimagemaptool-settings.c
app/tools/gimpimagemaptool.c
app/tools/gimpinkoptions-gui.c
app/tools/gimpinktool.c
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]