Commit e86e0032 authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann

Add Desaturate as an image-map tool with live preview (bug #533808):

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.

svn path=/trunk/; revision=25726
parent 1e3a887d
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.
2008-05-21 Sven Neumann <sven@gimp.org>
* plug-ins/jpeg/jpeg-save.c (save_dialog): changed badly chosen
......
......@@ -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 @@ drawable_actions_update (GimpActionGroup *group,
#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);
......
......@@ -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,49 +44,8 @@
#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 @@ drawable_rotate_cmd_callback (GtkAction *action,
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);
}
......@@ -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 @@ void drawable_rotate_cmd_callback (GtkAction *action,
gint value,
gpointer data);
#endif /* __DRAWABLE_COMMANDS_H__ */
......@@ -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 @@ gimp_drawable_desaturate (GimpDrawable *drawable,
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"));
......
......@@ -26,8 +26,6 @@ libappdialogs_a_sources = \
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 \
......
/* 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>
#include "libgimpwidgets/gimpwidgets.h"
#include "dialogs-types.h"
#include "core/gimpcontext.h"
#include "core/gimplayer.h"
#include "widgets/gimphelp-ids.h"
#include "widgets/gimpviewabledialog.h"
#include "desaturate-dialog.h"
#include "gimp-intl.h"
static void desaturate_dialog_free (DesaturateDialog *dialog);
DesaturateDialog *
desaturate_dialog_new (GimpDrawable *drawable,
GimpContext *context,
GtkWidget *parent,
GimpDesaturateMode mode)
{
DesaturateDialog *dialog;
GtkWidget *vbox;
GtkWidget *frame;
GtkWidget *button;
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), NULL);
g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
g_return_val_if_fail (GTK_IS_WIDGET (parent), NULL);
dialog = g_slice_new0 (DesaturateDialog);
dialog->drawable = drawable;
dialog->mode = mode;
dialog->dialog =
gimp_viewable_dialog_new (GIMP_VIEWABLE (drawable), context,
_("Desaturate"), "gimp-drawable-desaturate",
GIMP_STOCK_CONVERT_GRAYSCALE,
_("Remove Colors"),
parent,
gimp_standard_help_func,
GIMP_HELP_LAYER_DESATURATE,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
NULL);
button = gtk_dialog_add_button (GTK_DIALOG (dialog->dialog),
_("_Desaturate"), GTK_RESPONSE_OK);
gtk_button_set_image (GTK_BUTTON (button),
gtk_image_new_from_stock (GIMP_STOCK_CONVERT_GRAYSCALE,
GTK_ICON_SIZE_BUTTON));
gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog->dialog),
GTK_RESPONSE_OK,
GTK_RESPONSE_CANCEL,
-1);
gtk_window_set_resizable (GTK_WINDOW (dialog->dialog), FALSE);
g_object_weak_ref (G_OBJECT (dialog->dialog),
(GWeakNotify) desaturate_dialog_free, dialog);
vbox = gtk_vbox_new (FALSE, 12);
gtk_container_set_border_width (GTK_CONTAINER (vbox), 12);
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog->dialog)->vbox), vbox);
gtk_widget_show (vbox);
frame =
gimp_enum_radio_frame_new (GIMP_TYPE_DESATURATE_MODE,
gtk_label_new (_("Choose shade of gray based on:")),
G_CALLBACK (gimp_radio_button_update),
&dialog->mode,
&button);
gimp_int_radio_group_set_active (GTK_RADIO_BUTTON (button), dialog->mode);
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
gtk_widget_show (frame);
return dialog;
}
static void
desaturate_dialog_free (DesaturateDialog *dialog)
{
g_slice_free (DesaturateDialog, dialog);
}
......@@ -49,11 +49,11 @@ GimpDialogFactory *global_display_factory = NULL;
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 @@ static const GimpDialogFactoryEntry toplevel_entries[] =
{
/* 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),
......
......@@ -17,6 +17,8 @@ libappgegl_a_SOURCES = \
gimpcolorizeconfig.h \
gimpcurvesconfig.c \
gimpcurvesconfig.h \
gimpdesaturateconfig.c \
gimpdesaturateconfig.h \
gimphuesaturationconfig.c \
gimphuesaturationconfig.h \
gimplevelsconfig.c \
......
......@@ -47,6 +47,7 @@ typedef struct _GimpBrightnessContrastConfig GimpBrightnessContrastConfig;
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;
......
/* 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;
}
}
/* 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
......@@ -16,25 +19,37 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __DESATURATE_DIALOG_H__
#define __DESATURATE_DIALOG_H__
#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 _DesaturateDialog DesaturateDialog;
struct _DesaturateDialog
typedef struct _GimpDesaturateConfigClass GimpDesaturateConfigClass;
struct _GimpDesaturateConfig
{
GtkWidget *dialog;
GimpImageMapConfig parent_instance;
GimpDrawable *drawable;
GimpDesaturateMode mode;
};
struct _GimpDesaturateConfigClass
{
GimpImageMapConfigClass parent_class;
};
DesaturateDialog * desaturate_dialog_new (GimpDrawable *drawable,
GimpContext *context,
GtkWidget *parent,
GimpDesaturateMode mode);
GType gimp_desaturate_config_get_type (void) G_GNUC_CONST;
#endif /* __DESATURATE_DIALOG_H__ */
#endif /* __GIMP_DESATURATE_CONFIG_H__ */
......@@ -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 @@ gimp_operation_desaturate_class_init (GimpOperationDesaturateClass *klass)
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 @@ gimp_operation_desaturate_class_init (GimpOperationDesaturateClass *klass)
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 @@ gimp_operation_desaturate_init (GimpOperationDesaturate *self)
{
}
static void
gimp_operation_desaturate_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
static gboolean
gimp_operation_desaturate_process (GeglOperation *operation,
void *in_buf,
void *out_buf,
glong samples)
{
GimpOperationDesaturate *self = GIMP_OPERATION_DESATURATE (object);
GimpOperationPointFilter *point = GIMP_OPERATION_POINT_FILTER (operation);
GimpDesaturateConfig *config = GIMP_DESATURATE_CONFIG (point->config);
gfloat *src = in_buf;
gfloat *dest = out_buf;
switch (property_id)
switch (config->mode)
{
case PROP_MODE:
g_value_set_enum (value, self->mode);
break;
case GIMP_DESATURATE_LIGHTNESS:
while (samples--)
{
gfloat min, max, value;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
max = MAX (src[0], src[1]);
max = MAX (max, src[2]);
min = MIN (src[0], src[1]);
min = MIN (min, src[2]);
static void
gimp_operation_desaturate_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
GimpOperationDesaturate *self = GIMP_OPERATION_DESATURATE (object);
value = (max + min) / 2;
switch (property_id)
{
case PROP_MODE:
self->mode = g_value_get_enum (value);
break;
dest[0] = value;
dest[1] = value;
dest[2] = value;
dest[3] = src[3];
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
src += 4;
dest += 4;
}
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;
case GIMP_DESATURATE_LUMINOSITY:
while (samples--)
{
gfloat value = GIMP_RGB_LUMINANCE (src[0], src[1], src[2]);
while (samples--)
{
gfloat value = 0.0;
dest[0] = value;
dest[1] = value;
dest[2] = value;
dest[3] = src[3];
switch (self->mode)
{
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;
src += 4;
dest += 4;
}
break;