From 00c525abbc3f00a85c94802fbddddc6bc0ade3db Mon Sep 17 00:00:00 2001 From: Michael Natterer Date: Sat, 24 Jan 2004 18:35:49 +0000 Subject: [PATCH] fiddle with the passed channel index only for GRAYA drawables, not for all 2004-01-24 Michael Natterer * tools/pdbgen/pdb/color.pdb (levels, curves): fiddle with the passed channel index only for GRAYA drawables, not for all GRAY drawables. Fixes bug #132322. * tools/pdbgen/pdb/color.pdb: regenerated. * app/tools/gimpcurvestool.[ch] * app/tools/gimplevelstool.[ch]: fixed the same bug here. It never occured because the "channel" field was accidentially initialized with the correct value and never changed after. --- ChangeLog | 13 +++++++++++++ app/pdb/color_cmds.c | 6 +++--- app/tools/gimpcurvestool.c | 10 ++++++++-- app/tools/gimpcurvestool.h | 1 + app/tools/gimplevelstool.c | 8 ++++++-- app/tools/gimplevelstool.h | 1 + tools/pdbgen/pdb/color.pdb | 6 +++--- 7 files changed, 35 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index f78fb8e3bd..97a29e67a9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2004-01-24 Michael Natterer + + * tools/pdbgen/pdb/color.pdb (levels, curves): fiddle with the + passed channel index only for GRAYA drawables, not for all GRAY + drawables. Fixes bug #132322. + + * tools/pdbgen/pdb/color.pdb: regenerated. + + * app/tools/gimpcurvestool.[ch] + * app/tools/gimplevelstool.[ch]: fixed the same bug here. It never + occured because the "channel" field was accidentially initialized + with the correct value and never changed after. + 2004-01-23 Simon Budig * plug-ins/common/mosaic.c: properly use src_rgn.rowstride when diff --git a/app/pdb/color_cmds.c b/app/pdb/color_cmds.c index ef3d800448..01a096a8e8 100644 --- a/app/pdb/color_cmds.c +++ b/app/pdb/color_cmds.c @@ -231,7 +231,7 @@ levels_invoker (Gimp *gimp, if (success) { /* FIXME: hack */ - if (gimp_drawable_is_gray (drawable)) + if (gimp_drawable_is_gray (drawable) && gimp_drawable_has_alpha (drawable)) channel = (channel > 1) ? 2 : 1; lut = gimp_lut_new (); @@ -686,7 +686,7 @@ curves_spline_invoker (Gimp *gimp, if (success) { /* FIXME: hack */ - if (gimp_drawable_is_gray (drawable)) + if (gimp_drawable_is_gray (drawable) && gimp_drawable_has_alpha (drawable)) channel = (channel > 1) ? 2 : 1; lut = gimp_lut_new (); @@ -808,7 +808,7 @@ curves_explicit_invoker (Gimp *gimp, if (success) { /* FIXME: hack */ - if (gimp_drawable_is_gray (drawable)) + if (gimp_drawable_is_gray (drawable) && gimp_drawable_has_alpha (drawable)) channel = (channel > 1) ? 2 : 1; lut = gimp_lut_new (); diff --git a/app/tools/gimpcurvestool.c b/app/tools/gimpcurvestool.c index ed65e93b9a..c48b39fbad 100644 --- a/app/tools/gimpcurvestool.c +++ b/app/tools/gimpcurvestool.c @@ -312,8 +312,9 @@ gimp_curves_tool_initialize (GimpTool *tool, curves_init (c_tool->curves); - c_tool->color = gimp_drawable_is_rgb (drawable); c_tool->channel = GIMP_HISTOGRAM_VALUE; + c_tool->color = gimp_drawable_is_rgb (drawable); + c_tool->alpha = gimp_drawable_has_alpha (drawable); c_tool->grab_point = -1; c_tool->last = 0; @@ -333,6 +334,9 @@ gimp_curves_tool_initialize (GimpTool *tool, gimp_int_option_menu_set_history (GTK_OPTION_MENU (c_tool->channel_menu), c_tool->channel); + if (! c_tool->color && c_tool->alpha) + c_tool->channel = 1; + curves_update (c_tool, ALL); gimp_drawable_calculate_histogram (drawable, c_tool->hist); @@ -797,7 +801,7 @@ curves_channel_callback (GtkWidget *widget, c_tool->channel); /* FIXME: hack */ - if (! c_tool->color) + if (! c_tool->color && c_tool->alpha) c_tool->channel = (c_tool->channel > 1) ? 2 : 1; gimp_int_radio_group_set_active (GTK_RADIO_BUTTON (c_tool->curve_type), @@ -828,10 +832,12 @@ curves_set_sensitive_callback (GimpHistogramChannel channel, { case GIMP_HISTOGRAM_VALUE: return TRUE; + case GIMP_HISTOGRAM_RED: case GIMP_HISTOGRAM_GREEN: case GIMP_HISTOGRAM_BLUE: return c_tool->color; + case GIMP_HISTOGRAM_ALPHA: return gimp_drawable_has_alpha (GIMP_IMAGE_MAP_TOOL (c_tool)->drawable); } diff --git a/app/tools/gimpcurvestool.h b/app/tools/gimpcurvestool.h index e57528d107..073426d897 100644 --- a/app/tools/gimpcurvestool.h +++ b/app/tools/gimpcurvestool.h @@ -42,6 +42,7 @@ struct _GimpCurvesTool /* dialog */ gboolean color; + gboolean alpha; GimpHistogramChannel channel; gint grab_point; diff --git a/app/tools/gimplevelstool.c b/app/tools/gimplevelstool.c index d056b0b429..17cf94d21a 100644 --- a/app/tools/gimplevelstool.c +++ b/app/tools/gimplevelstool.c @@ -305,6 +305,7 @@ gimp_levels_tool_initialize (GimpTool *tool, l_tool->channel = GIMP_HISTOGRAM_VALUE; l_tool->color = gimp_drawable_is_rgb (drawable); + l_tool->alpha = gimp_drawable_has_alpha (drawable); if (l_tool->active_picker) gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (l_tool->active_picker), @@ -319,7 +320,10 @@ gimp_levels_tool_initialize (GimpTool *tool, /* set the current selection */ gtk_option_menu_set_history (GTK_OPTION_MENU (l_tool->channel_menu), - l_tool->channel); + l_tool->channel); + + if (! l_tool->color && l_tool->alpha) + l_tool->channel = 1; levels_update (l_tool, ALL); @@ -939,7 +943,7 @@ levels_channel_callback (GtkWidget *widget, l_tool->channel); /* FIXME: hack */ - if (! l_tool->color) + if (! l_tool->color && l_tool->alpha) l_tool->channel = (l_tool->channel > 1) ? 2 : 1; levels_update (l_tool, ALL); diff --git a/app/tools/gimplevelstool.h b/app/tools/gimplevelstool.h index 8979076587..240df7634c 100644 --- a/app/tools/gimplevelstool.h +++ b/app/tools/gimplevelstool.h @@ -40,6 +40,7 @@ struct _GimpLevelsTool GimpLut *lut; gboolean color; + gboolean alpha; Levels *levels; /* dialog */ diff --git a/tools/pdbgen/pdb/color.pdb b/tools/pdbgen/pdb/color.pdb index 8b554be3e3..1d8c163e57 100644 --- a/tools/pdbgen/pdb/color.pdb +++ b/tools/pdbgen/pdb/color.pdb @@ -134,7 +134,7 @@ HELP if (success) { /* FIXME: hack */ - if (gimp_drawable_is_gray (drawable)) + if (gimp_drawable_is_gray (drawable) && gimp_drawable_has_alpha (drawable)) channel = (channel > 1) ? 2 : 1; lut = gimp_lut_new (); @@ -425,7 +425,7 @@ HELP if (success) { /* FIXME: hack */ - if (gimp_drawable_is_gray (drawable)) + if (gimp_drawable_is_gray (drawable) && gimp_drawable_has_alpha (drawable)) channel = (channel > 1) ? 2 : 1; lut = gimp_lut_new (); @@ -506,7 +506,7 @@ HELP if (success) { /* FIXME: hack */ - if (gimp_drawable_is_gray (drawable)) + if (gimp_drawable_is_gray (drawable) && gimp_drawable_has_alpha (drawable)) channel = (channel > 1) ? 2 : 1; lut = gimp_lut_new ();