fixed to work like gimp_hls_to_rgb_int() (does the right thing now for the

2003-05-19  Michael Natterer  <mitch@gimp.org>

	* libgimpcolor/gimpcolorspace.c (gimp_hsl_to_rgb): fixed to work
	like gimp_hls_to_rgb_int() (does the right thing now for the
	saturation == 0 case). Some minor cleanups.

	Implemented "Colorize" as suggested in bug #20509. It's not a
	toggle in the "Hue/Saturation" tool dialog (which would be a gross
	hack IMHO) but a separate tool. Fixes bug #20509.

	* app/base/Makefile.am
	* app/base/base-types.h
	* app/base/colorize.[ch]: the actual mapping function lives
	here. Its algorithm was taken from the "colorify" plug-in.

	* app/tools/Makefile.am
	* app/tools/gimpcolorizetool.[ch]: the tool.

	* app/tools/tools.c: register it.

	* app/gui/dialogs.c: session-manage its dialog.

	* libgimpwidgets/gimpstock.[ch]
	* themes/Default/images/Makefile.am
	* themes/Default/images/tools/stock-tool-colorize-16.png
	* themes/Default/images/tools/stock-tool-colorize-22.png: new
	icons from Jimmac.

	Unrelated:

	* app/tools/gimpbrightnesscontrasttool.c
	* app/tools/gimpcolorbalancetool.c
	* app/tools/gimphuesaturationtool.c
	* app/tools/gimpposterizetool.c
	* app/tools/gimpthresholdtool.c: don't #include "tool_manager.h"
This commit is contained in:
Michael Natterer 2003-05-19 14:21:03 +00:00 committed by Michael Natterer
parent 930f383df4
commit 49b851780e
22 changed files with 664 additions and 21 deletions

View File

@ -1,3 +1,39 @@
2003-05-19 Michael Natterer <mitch@gimp.org>
* libgimpcolor/gimpcolorspace.c (gimp_hsl_to_rgb): fixed to work
like gimp_hls_to_rgb_int() (does the right thing now for the
saturation == 0 case). Some minor cleanups.
Implemented "Colorize" as suggested in bug #20509. It's not a
toggle in the "Hue/Saturation" tool dialog (which would be a gross
hack IMHO) but a separate tool. Fixes bug #20509.
* app/base/Makefile.am
* app/base/base-types.h
* app/base/colorize.[ch]: the actual mapping function lives
here. Its algorithm was taken from the "colorify" plug-in.
* app/tools/Makefile.am
* app/tools/gimpcolorizetool.[ch]: the tool.
* app/tools/tools.c: register it.
* app/gui/dialogs.c: session-manage its dialog.
* libgimpwidgets/gimpstock.[ch]
* themes/Default/images/Makefile.am
* themes/Default/images/tools/stock-tool-colorize-16.png
* themes/Default/images/tools/stock-tool-colorize-22.png: new
icons from Jimmac.
Unrelated:
* app/tools/gimpbrightnesscontrasttool.c
* app/tools/gimpcolorbalancetool.c
* app/tools/gimphuesaturationtool.c
* app/tools/gimpposterizetool.c
* app/tools/gimpthresholdtool.c: don't #include "tool_manager.h"
2003-05-19 Manish Singh <yosh@gimp.org>
* configure.in: remove glibconfig.h inline check, it hasn't worked

View File

@ -20,6 +20,8 @@ libappbase_a_SOURCES = \
brush-scale.h \
color-balance.c \
color-balance.h \
colorize.c \
colorize.h \
curves.c \
curves.h \
$(mmx_sources) \

View File

@ -51,6 +51,7 @@ typedef struct _GimpHistogram GimpHistogram;
typedef struct _GimpLut GimpLut;
typedef struct _ColorBalance ColorBalance;
typedef struct _Colorize Colorize;
typedef struct _Curves Curves;
typedef struct _HueSaturation HueSaturation;
typedef struct _Levels Levels;

116
app/base/colorize.c Normal file
View File

@ -0,0 +1,116 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <glib-object.h>
#include "libgimpcolor/gimpcolor.h"
#include "libgimpmath/gimpmath.h"
#include "base-types.h"
#include "colorize.h"
#include "pixel-region.h"
void
colorize_init (Colorize *colorize)
{
gint i;
g_return_if_fail (colorize != NULL);
colorize->hue = 0.0;
colorize->lightness = 100.0;
colorize->saturation = 100.0;
for (i = 0; i < 256; i ++)
{
colorize->lum_red_lookup[i] = i * INTENSITY_RED;
colorize->lum_green_lookup[i] = i * INTENSITY_GREEN;
colorize->lum_blue_lookup[i] = i * INTENSITY_BLUE;
}
}
void
colorize_calculate (Colorize *colorize)
{
GimpRGB color;
gint i;
g_return_if_fail (colorize != NULL);
gimp_hsl_to_rgb (colorize->hue,
colorize->saturation / 100.0,
colorize->lightness / 100.0,
&color);
/* Calculate transfers */
for (i = 0; i < 256; i ++)
{
colorize->final_red_lookup[i] = i * color.r;
colorize->final_green_lookup[i] = i * color.g;
colorize->final_blue_lookup[i] = i * color.b;
}
}
void
colorize (PixelRegion *srcPR,
PixelRegion *destPR,
Colorize *colorize)
{
guchar *src, *s;
guchar *dest, *d;
gboolean alpha;
gint w, h;
gint lum;
/* Set the transfer arrays (for speed) */
h = srcPR->h;
src = srcPR->data;
dest = destPR->data;
alpha = (srcPR->bytes == 4) ? TRUE : FALSE;
while (h--)
{
w = srcPR->w;
s = src;
d = dest;
while (w--)
{
lum = (colorize->lum_red_lookup[s[RED_PIX]] +
colorize->lum_green_lookup[s[GREEN_PIX]] +
colorize->lum_blue_lookup[s[BLUE_PIX]]); /* luminosity */
d[RED_PIX] = colorize->final_red_lookup[lum];
d[GREEN_PIX] = colorize->final_green_lookup[lum];
d[BLUE_PIX] = colorize->final_blue_lookup[lum];
if (alpha)
d[ALPHA_PIX] = s[ALPHA_PIX];
s += srcPR->bytes;
d += destPR->bytes;
}
src += srcPR->rowstride;
dest += destPR->rowstride;
}
}

46
app/base/colorize.h Normal file
View File

@ -0,0 +1,46 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __COLORIZE_H__
#define __COLORIZE_H__
struct _Colorize
{
gdouble hue;
gdouble lightness;
gdouble saturation;
gint lum_red_lookup[256];
gint lum_green_lookup[256];
gint lum_blue_lookup[256];
gint final_red_lookup[256];
gint final_green_lookup[256];
gint final_blue_lookup[256];
};
void colorize_init (Colorize *colorize);
void colorize_calculate (Colorize *colorize);
void colorize (PixelRegion *srcPR,
PixelRegion *destPR,
Colorize *colorize);
#endif /* __COLORIZE_H__ */

View File

@ -50,6 +50,8 @@ static const GimpDialogFactoryEntry toplevel_entries[] =
NULL, 0, TRUE, TRUE, FALSE, FALSE },
{ "gimp-color-picker-tool-dialog",
NULL, 0, TRUE, TRUE, FALSE, FALSE },
{ "gimp-colorize-tool-dialog",
NULL, 0, TRUE, TRUE, FALSE, FALSE },
{ "gimp-crop-tool-dialog",
NULL, 0, TRUE, TRUE, FALSE, FALSE },
{ "gimp-curves-tool-dialog",

View File

@ -50,6 +50,8 @@ static const GimpDialogFactoryEntry toplevel_entries[] =
NULL, 0, TRUE, TRUE, FALSE, FALSE },
{ "gimp-color-picker-tool-dialog",
NULL, 0, TRUE, TRUE, FALSE, FALSE },
{ "gimp-colorize-tool-dialog",
NULL, 0, TRUE, TRUE, FALSE, FALSE },
{ "gimp-crop-tool-dialog",
NULL, 0, TRUE, TRUE, FALSE, FALSE },
{ "gimp-curves-tool-dialog",

View File

@ -27,6 +27,8 @@ libapptools_a_sources = \
gimpclonetool.h \
gimpcolorbalancetool.c \
gimpcolorbalancetool.h \
gimpcolorizetool.c \
gimpcolorizetool.h \
gimpcolorpickeroptions.c \
gimpcolorpickeroptions.h \
gimpcolorpickertool.c \

View File

@ -35,7 +35,6 @@
#include "display/gimpdisplay.h"
#include "gimpbrightnesscontrasttool.h"
#include "tool_manager.h"
#include "gimp-intl.h"

View File

@ -37,7 +37,6 @@
#include "widgets/gimpenummenu.h"
#include "gimpcolorbalancetool.h"
#include "tool_manager.h"
#include "gimp-intl.h"

View File

@ -0,0 +1,365 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <gtk/gtk.h>
#include "libgimpcolor/gimpcolor.h"
#include "libgimpmath/gimpmath.h"
#include "libgimpwidgets/gimpwidgets.h"
#include "tools-types.h"
#include "base/colorize.h"
#include "core/gimpdrawable.h"
#include "core/gimpimage.h"
#include "core/gimpimagemap.h"
#include "display/gimpdisplay.h"
#include "gimpcolorizetool.h"
#include "gimp-intl.h"
#define SLIDER_WIDTH 200
#define DA_WIDTH 40
#define DA_HEIGHT 20
#define HUE_SLIDER (1 << 0)
#define LIGHTNESS_SLIDER (1 << 1)
#define SATURATION_SLIDER (1 << 2)
#define DRAW (1 << 3)
#define SLIDERS (HUE_SLIDER | LIGHTNESS_SLIDER | SATURATION_SLIDER)
#define ALL (SLIDERS | DRAW)
/* local function prototypes */
static void gimp_colorize_tool_class_init (GimpColorizeToolClass *klass);
static void gimp_colorize_tool_init (GimpColorizeTool *tool);
static void gimp_colorize_tool_finalize (GObject *object);
static void gimp_colorize_tool_initialize (GimpTool *tool,
GimpDisplay *gdisp);
static void gimp_colorize_tool_map (GimpImageMapTool *image_map_tool);
static void gimp_colorize_tool_dialog (GimpImageMapTool *image_map_tool);
static void gimp_colorize_tool_reset (GimpImageMapTool *image_map_tool);
static void colorize_update (GimpColorizeTool *col_tool,
gint update);
static void colorize_hue_adj_update (GtkAdjustment *adj,
GimpColorizeTool *col_tool);
static void colorize_lightness_adj_update (GtkAdjustment *adj,
GimpColorizeTool *col_tool);
static void colorize_saturation_adj_update (GtkAdjustment *adj,
GimpColorizeTool *col_tool);
/* private variables */
static GimpImageMapToolClass *parent_class = NULL;
/* public functions */
void
gimp_colorize_tool_register (GimpToolRegisterCallback callback,
gpointer data)
{
(* callback) (GIMP_TYPE_COLORIZE_TOOL,
G_TYPE_NONE, NULL,
FALSE,
"gimp-colorize-tool",
_("Colorize"),
_("Colorize the image"),
N_("/Layer/Colors/Colorize..."), NULL,
NULL, "tools/colorize.html",
GIMP_STOCK_TOOL_COLORIZE,
data);
}
GType
gimp_colorize_tool_get_type (void)
{
static GType tool_type = 0;
if (! tool_type)
{
static const GTypeInfo tool_info =
{
sizeof (GimpColorizeToolClass),
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) gimp_colorize_tool_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (GimpColorizeTool),
0, /* n_preallocs */
(GInstanceInitFunc) gimp_colorize_tool_init,
};
tool_type = g_type_register_static (GIMP_TYPE_IMAGE_MAP_TOOL,
"GimpColorizeTool",
&tool_info, 0);
}
return tool_type;
}
/* private functions */
static void
gimp_colorize_tool_class_init (GimpColorizeToolClass *klass)
{
GObjectClass *object_class;
GimpToolClass *tool_class;
GimpImageMapToolClass *image_map_tool_class;
object_class = G_OBJECT_CLASS (klass);
tool_class = GIMP_TOOL_CLASS (klass);
image_map_tool_class = GIMP_IMAGE_MAP_TOOL_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
object_class->finalize = gimp_colorize_tool_finalize;
tool_class->initialize = gimp_colorize_tool_initialize;
image_map_tool_class->map = gimp_colorize_tool_map;
image_map_tool_class->dialog = gimp_colorize_tool_dialog;
image_map_tool_class->reset = gimp_colorize_tool_reset;
}
static void
gimp_colorize_tool_init (GimpColorizeTool *col_tool)
{
GimpImageMapTool *image_map_tool;
image_map_tool = GIMP_IMAGE_MAP_TOOL (col_tool);
image_map_tool->shell_identifier = "gimp-colorize-tool-dialog";
image_map_tool->shell_desc = _("Colorize the Image");
col_tool->colorize = g_new0 (Colorize, 1);
colorize_init (col_tool->colorize);
}
static void
gimp_colorize_tool_finalize (GObject *object)
{
GimpColorizeTool *col_tool;
col_tool = GIMP_COLORIZE_TOOL (object);
if (col_tool->colorize)
{
g_free (col_tool->colorize);
col_tool->colorize = NULL;
}
G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
gimp_colorize_tool_initialize (GimpTool *tool,
GimpDisplay *gdisp)
{
GimpColorizeTool *col_tool;
col_tool = GIMP_COLORIZE_TOOL (tool);
if (! gimp_drawable_is_rgb (gimp_image_active_drawable (gdisp->gimage)))
{
g_message (_("Colorize operates only on RGB color drawables."));
return;
}
colorize_init (col_tool->colorize);
GIMP_TOOL_CLASS (parent_class)->initialize (tool, gdisp);
colorize_update (col_tool, ALL);
gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (tool));
}
static void
gimp_colorize_tool_map (GimpImageMapTool *image_map_tool)
{
GimpColorizeTool *col_tool;
col_tool = GIMP_COLORIZE_TOOL (image_map_tool);
gimp_image_map_apply (image_map_tool->image_map,
(GimpImageMapApplyFunc) colorize,
col_tool->colorize);
}
/***************************/
/* Hue-Saturation dialog */
/***************************/
static void
gimp_colorize_tool_dialog (GimpImageMapTool *image_map_tool)
{
GimpColorizeTool *col_tool;
GtkWidget *table;
GtkWidget *slider;
GtkWidget *frame;
GtkWidget *vbox;
GtkObject *data;
col_tool = GIMP_COLORIZE_TOOL (image_map_tool);
frame = gtk_frame_new (_("Select Color"));
gtk_box_pack_start (GTK_BOX (image_map_tool->main_vbox), frame,
FALSE, FALSE, 0);
gtk_widget_show (frame);
/* The table containing sliders */
vbox = gtk_vbox_new (FALSE, 4);
gtk_container_set_border_width (GTK_CONTAINER (vbox), 2);
gtk_container_add (GTK_CONTAINER (frame), vbox);
gtk_widget_show (vbox);
table = gtk_table_new (3, 3, FALSE);
gtk_table_set_col_spacings (GTK_TABLE (table), 4);
gtk_table_set_row_spacings (GTK_TABLE (table), 2);
gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, FALSE, 0);
gtk_widget_show (table);
/* 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,
TRUE, 0.0, 0.0,
NULL, NULL);
col_tool->hue_data = GTK_ADJUSTMENT (data);
slider = GIMP_SCALE_ENTRY_SCALE (data);
gtk_range_set_update_policy (GTK_RANGE (slider), GTK_UPDATE_DELAYED);
g_signal_connect (data, "value_changed",
G_CALLBACK (colorize_hue_adj_update),
col_tool);
/* Create the lightness scale widget */
data = gimp_scale_entry_new (GTK_TABLE (table), 0, 1,
_("_Lightness:"), SLIDER_WIDTH, -1,
0.0, 0.0, 100.0, 1.0, 10.0, 0,
TRUE, 0.0, 0.0,
NULL, NULL);
col_tool->lightness_data = GTK_ADJUSTMENT (data);
slider = GIMP_SCALE_ENTRY_SCALE (data);
gtk_range_set_update_policy (GTK_RANGE (slider), GTK_UPDATE_DELAYED);
g_signal_connect (data, "value_changed",
G_CALLBACK (colorize_lightness_adj_update),
col_tool);
/* Create the saturation scale widget */
data = gimp_scale_entry_new (GTK_TABLE (table), 0, 2,
_("_Saturation:"), SLIDER_WIDTH, -1,
0.0, 0.0, 100.0, 1.0, 10.0, 0,
TRUE, 0.0, 0.0,
NULL, NULL);
col_tool->saturation_data = GTK_ADJUSTMENT (data);
slider = GIMP_SCALE_ENTRY_SCALE (data);
gtk_range_set_update_policy (GTK_RANGE (slider), GTK_UPDATE_DELAYED);
g_signal_connect (col_tool->saturation_data, "value_changed",
G_CALLBACK (colorize_saturation_adj_update),
col_tool);
}
static void
gimp_colorize_tool_reset (GimpImageMapTool *image_map_tool)
{
GimpColorizeTool *col_tool;
col_tool = GIMP_COLORIZE_TOOL (image_map_tool);
colorize_init (col_tool->colorize);
colorize_update (col_tool, ALL);
}
static void
colorize_update (GimpColorizeTool *col_tool,
gint update)
{
colorize_calculate (col_tool->colorize);
if (update & HUE_SLIDER)
gtk_adjustment_set_value (GTK_ADJUSTMENT (col_tool->hue_data),
col_tool->colorize->hue);
if (update & LIGHTNESS_SLIDER)
gtk_adjustment_set_value (GTK_ADJUSTMENT (col_tool->lightness_data),
col_tool->colorize->lightness);
if (update & SATURATION_SLIDER)
gtk_adjustment_set_value (GTK_ADJUSTMENT (col_tool->saturation_data),
col_tool->colorize->saturation);
}
static void
colorize_hue_adj_update (GtkAdjustment *adjustment,
GimpColorizeTool *col_tool)
{
if (col_tool->colorize->hue != adjustment->value)
{
col_tool->colorize->hue = adjustment->value;
colorize_update (col_tool, DRAW);
gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (col_tool));
}
}
static void
colorize_lightness_adj_update (GtkAdjustment *adjustment,
GimpColorizeTool *col_tool)
{
if (col_tool->colorize->lightness != adjustment->value)
{
col_tool->colorize->lightness = adjustment->value;
colorize_update (col_tool, DRAW);
gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (col_tool));
}
}
static void
colorize_saturation_adj_update (GtkAdjustment *adjustment,
GimpColorizeTool *col_tool)
{
if (col_tool->colorize->saturation != adjustment->value)
{
col_tool->colorize->saturation = adjustment->value;
colorize_update (col_tool, DRAW);
gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (col_tool));
}
}

View File

@ -0,0 +1,61 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __GIMP_COLORIZE_TOOL_H__
#define __GIMP_COLORIZE_TOOL_H__
#include "gimpimagemaptool.h"
#define GIMP_TYPE_COLORIZE_TOOL (gimp_colorize_tool_get_type ())
#define GIMP_COLORIZE_TOOL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_COLORIZE_TOOL, GimpColorizeTool))
#define GIMP_COLORIZE_TOOL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_COLORIZE_TOOL, GimpColorizeToolClass))
#define GIMP_IS_COLORIZE_TOOL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_COLORIZE_TOOL))
#define GIMP_IS_COLORIZE_TOOL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_COLORIZE_TOOL))
#define GIMP_COLORIZE_TOOL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_COLORIZE_TOOL, GimpColorizeToolClass))
typedef struct _GimpColorizeTool GimpColorizeTool;
typedef struct _GimpColorizeToolClass GimpColorizeToolClass;
struct _GimpColorizeTool
{
GimpImageMapTool parent_instance;
Colorize *colorize;
/* dialog */
GtkAdjustment *hue_data;
GtkAdjustment *lightness_data;
GtkAdjustment *saturation_data;
};
struct _GimpColorizeToolClass
{
GimpImageMapToolClass parent_class;
};
void gimp_colorize_tool_register (GimpToolRegisterCallback callback,
gpointer data);
GType gimp_colorize_tool_get_type (void) G_GNUC_CONST;
#endif /* __GIMP_COLORIZE_TOOL_H__ */

View File

@ -35,7 +35,6 @@
#include "display/gimpdisplay.h"
#include "gimphuesaturationtool.h"
#include "tool_manager.h"
#include "gimp-intl.h"

View File

@ -34,7 +34,6 @@
#include "display/gimpdisplay.h"
#include "gimpposterizetool.h"
#include "tool_manager.h"
#include "gimp-intl.h"

View File

@ -42,7 +42,6 @@
#include "display/gimpdisplay.h"
#include "gimpthresholdtool.h"
#include "tool_manager.h"
#include "gimp-intl.h"

View File

@ -34,6 +34,7 @@
#include "gimpbycolorselecttool.h"
#include "gimpclonetool.h"
#include "gimpcolorbalancetool.h"
#include "gimpcolorizetool.h"
#include "gimpcolorpickertool.h"
#include "gimpconvolvetool.h"
#include "gimpcroptool.h"
@ -79,6 +80,7 @@ tools_init (Gimp *gimp)
gimp_levels_tool_register,
gimp_threshold_tool_register,
gimp_brightness_contrast_tool_register,
gimp_colorize_tool_register,
gimp_hue_saturation_tool_register,
gimp_color_balance_tool_register,

View File

@ -216,9 +216,9 @@ gimp_rgb_to_hsl (const GimpRGB *rgb,
}
static gdouble
_gimp_color_value (gdouble n1,
gdouble n2,
gdouble hue)
gimp_hsl_value (gdouble n1,
gdouble n2,
gdouble hue)
{
gdouble val;
@ -226,6 +226,7 @@ _gimp_color_value (gdouble n1,
hue = hue - 360.0;
else if (hue < 0.0)
hue = hue + 360.0;
if (hue < 60.0)
val = n1 + (n2 - n1) * hue / 60.0;
else if (hue < 180.0)
@ -244,26 +245,30 @@ gimp_hsl_to_rgb (gdouble hue,
gdouble lightness,
GimpRGB *rgb)
{
gdouble m1, m2;
g_return_if_fail (rgb != NULL);
if (lightness <= 0.5)
m2 = lightness * (1.0 + saturation);
else
m2 = lightness + saturation - lightness * saturation;
m1 = 2.0 * lightness - m2;
if (saturation == 0)
{
if (hue == GIMP_HSV_UNDEFINED)
rgb->r = rgb->g = rgb->b = 1.0;
/* achromatic case */
rgb->r = lightness;
rgb->g = lightness;
rgb->b = lightness;
}
else
{
rgb->r = _gimp_color_value (m1, m2, hue + 120.0);
rgb->g = _gimp_color_value (m1, m2, hue);
rgb->b = _gimp_color_value (m1, m2, hue - 120.0);
gdouble m1, m2;
if (lightness <= 0.5)
m2 = lightness * (1.0 + saturation);
else
m2 = lightness + saturation - lightness * saturation;
m1 = 2.0 * lightness - m2;
rgb->r = gimp_hsl_value (m1, m2, hue + 120.0);
rgb->g = gimp_hsl_value (m1, m2, hue);
rgb->b = gimp_hsl_value (m1, m2, hue - 120.0);
}
}
@ -582,6 +587,7 @@ gimp_hls_value (gdouble n1,
hue -= 255;
else if (hue < 0)
hue += 255;
if (hue < 42.5)
value = n1 + (n2 - n1) * (hue / 42.5);
else if (hue < 127.5)
@ -600,7 +606,6 @@ gimp_hls_to_rgb_int (gint *hue,
gint *saturation)
{
gdouble h, l, s;
gdouble m1, m2;
h = *hue;
l = *lightness;
@ -615,6 +620,8 @@ gimp_hls_to_rgb_int (gint *hue,
}
else
{
gdouble m1, m2;
if (l < 128)
m2 = (l * (255 + s)) / 65025.0;
else

View File

@ -228,6 +228,7 @@ static GtkStockItem gimp_stock_items[] =
{ GIMP_STOCK_TOOL_CLONE, NULL, 0, 0, LIBGIMP_DOMAIN },
{ GIMP_STOCK_TOOL_COLOR_BALANCE, NULL, 0, 0, LIBGIMP_DOMAIN },
{ GIMP_STOCK_TOOL_COLOR_PICKER, NULL, 0, 0, LIBGIMP_DOMAIN },
{ GIMP_STOCK_TOOL_COLORIZE, NULL, 0, 0, LIBGIMP_DOMAIN },
{ GIMP_STOCK_TOOL_CROP, N_("Crop"), 0, 0, LIBGIMP_DOMAIN },
{ GIMP_STOCK_TOOL_CURVES, NULL, 0, 0, LIBGIMP_DOMAIN },
{ GIMP_STOCK_TOOL_DODGE, NULL, 0, 0, LIBGIMP_DOMAIN },
@ -339,6 +340,7 @@ gimp_stock_button_pixbufs[] =
{ GIMP_STOCK_TOOL_CLONE, stock_tool_clone_22 },
{ GIMP_STOCK_TOOL_COLOR_BALANCE, stock_tool_color_balance_22 },
{ GIMP_STOCK_TOOL_COLOR_PICKER, stock_tool_color_picker_22 },
{ GIMP_STOCK_TOOL_COLORIZE, stock_tool_colorize_22 },
{ GIMP_STOCK_TOOL_CROP, stock_tool_crop_22 },
{ GIMP_STOCK_TOOL_CURVES, stock_tool_curves_22 },
{ GIMP_STOCK_TOOL_DODGE, stock_tool_dodge_22 },
@ -460,6 +462,7 @@ gimp_stock_menu_pixbufs[] =
{ GIMP_STOCK_TOOL_CLONE, stock_tool_clone_16 },
{ GIMP_STOCK_TOOL_COLOR_BALANCE, stock_tool_color_balance_16 },
{ GIMP_STOCK_TOOL_COLOR_PICKER, stock_tool_color_picker_16 },
{ GIMP_STOCK_TOOL_COLORIZE, stock_tool_colorize_16 },
{ GIMP_STOCK_TOOL_CROP, stock_tool_crop_16 },
{ GIMP_STOCK_TOOL_CURVES, stock_tool_curves_16 },
{ GIMP_STOCK_TOOL_DODGE, stock_tool_dodge_16 },

View File

@ -101,6 +101,7 @@ G_BEGIN_DECLS
#define GIMP_STOCK_TOOL_CLONE "gimp-tool-clone"
#define GIMP_STOCK_TOOL_COLOR_BALANCE "gimp-tool-color-balance"
#define GIMP_STOCK_TOOL_COLOR_PICKER "gimp-tool-color-picker"
#define GIMP_STOCK_TOOL_COLORIZE "gimp-tool-colorize"
#define GIMP_STOCK_TOOL_CROP "gimp-tool-crop"
#define GIMP_STOCK_TOOL_CURVES "gimp-tool-curves"
#define GIMP_STOCK_TOOL_DODGE "gimp-tool-dodge"

View File

@ -197,6 +197,8 @@ STOCK_TOOL_IMAGES = \
tools/stock-tool-color-balance-22.png \
tools/stock-tool-color-picker-16.png \
tools/stock-tool-color-picker-22.png \
tools/stock-tool-colorize-16.png \
tools/stock-tool-colorize-22.png \
tools/stock-tool-crop-16.png \
tools/stock-tool-crop-22.png \
tools/stock-tool-curves-16.png \

Binary file not shown.

After

Width:  |  Height:  |  Size: 594 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 699 B