mirror of
https://gitlab.gnome.org/GNOME/gimp
synced 2024-10-21 12:02:32 +00:00
2004-06-28 Michael Natterer <mitch@gimp.org> Fixed bug #141930 while keeping bug #132322 fixed: * app/base/curves.c (curves_lut_func) * app/base/levels.c (levels_lut_func): changed meaning of channel slots for GRAYA images: just as for GRAY images, expect the value channel in slot 0 and the alpha channel in slot 1, so it matches the meaning of slots of GimpHistogram (before this change, only GRAY images had their value in slot 0 and GRAYA images had it in slot 1, whereas the histogram had the value channel in slot 0, which was breaking auto levels for GRAYA images). * app/tools/gimpcurvestool.c * app/tools/gimplevelstool.c * tools/pdbgen/pdb/color.pdb: adjusted channel fiddling for GRAY and GRAYA images accordingly. * app/tools/gimpcurvestool.c (curves_update) * app/tools/gimplevelstool.c (levels_update): call gimp_color_bar_set_buffers() with the right buffers. * app/pdb/color_cmds.c: regenerated.
This commit is contained in:
parent
b9c23cac5d
commit
a2850f6df2
24
ChangeLog
24
ChangeLog
|
@ -1,3 +1,27 @@
|
|||
2004-06-28 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
Fixed bug #141930 while keeping bug #132322 fixed:
|
||||
|
||||
* app/base/curves.c (curves_lut_func)
|
||||
* app/base/levels.c (levels_lut_func): changed meaning of channel
|
||||
slots for GRAYA images: just as for GRAY images, expect the value
|
||||
channel in slot 0 and the alpha channel in slot 1, so it matches
|
||||
the meaning of slots of GimpHistogram (before this change, only
|
||||
GRAY images had their value in slot 0 and GRAYA images had it in
|
||||
slot 1, whereas the histogram had the value channel in slot 0,
|
||||
which was breaking auto levels for GRAYA images).
|
||||
|
||||
* app/tools/gimpcurvestool.c
|
||||
* app/tools/gimplevelstool.c
|
||||
* tools/pdbgen/pdb/color.pdb: adjusted channel fiddling for GRAY
|
||||
and GRAYA images accordingly.
|
||||
|
||||
* app/tools/gimpcurvestool.c (curves_update)
|
||||
* app/tools/gimplevelstool.c (levels_update): call
|
||||
gimp_color_bar_set_buffers() with the right buffers.
|
||||
|
||||
* app/pdb/color_cmds.c: regenerated.
|
||||
|
||||
2004-06-28 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* app/gui/gui.c (gui_initialize_after_callback): select the
|
||||
|
|
|
@ -156,7 +156,7 @@ curves_calculate_curve (Curves *curves,
|
|||
|
||||
gfloat
|
||||
curves_lut_func (Curves *curves,
|
||||
gint nchannels,
|
||||
gint n_channels,
|
||||
gint channel,
|
||||
gfloat value)
|
||||
{
|
||||
|
@ -165,33 +165,39 @@ curves_lut_func (Curves *curves,
|
|||
gdouble inten;
|
||||
gint j;
|
||||
|
||||
if (nchannels == 1)
|
||||
j = 0;
|
||||
if (n_channels <= 2)
|
||||
j = channel;
|
||||
else
|
||||
j = channel + 1;
|
||||
|
||||
inten = value;
|
||||
|
||||
/* For color images this runs through the loop with j = channel +1
|
||||
the first time and j = 0 the second time */
|
||||
/* For bw images this runs through the loop with j = 0 the first and
|
||||
only time */
|
||||
/* For RGB and RGBA images this runs through the loop with j = channel + 1
|
||||
* the first time and j = 0 the second time
|
||||
*
|
||||
* For GRAY images this runs through the loop with j = 0 the first and
|
||||
* only time
|
||||
*/
|
||||
for (; j >= 0; j -= (channel + 1))
|
||||
{
|
||||
/* don't apply the overall curve to the alpha channel */
|
||||
if (j == 0 && (nchannels == 2 || nchannels == 4)
|
||||
&& channel == nchannels -1)
|
||||
if (j == 0 && (n_channels == 2 || n_channels == 4) &&
|
||||
channel == n_channels - 1)
|
||||
return inten;
|
||||
|
||||
if (inten < 0.0)
|
||||
inten = curves->curve[j][0]/255.0;
|
||||
{
|
||||
inten = curves->curve[j][0]/255.0;
|
||||
}
|
||||
else if (inten >= 1.0)
|
||||
inten = curves->curve[j][255]/255.0;
|
||||
{
|
||||
inten = curves->curve[j][255]/255.0;
|
||||
}
|
||||
else /* interpolate the curve */
|
||||
{
|
||||
index = floor(inten * 255.0);
|
||||
f = inten*255.0 - index;
|
||||
inten = ((1.0 - f) * curves->curve[j][index ] +
|
||||
inten = ((1.0 - f) * curves->curve[j][index ] +
|
||||
( f) * curves->curve[j][index + 1] ) / 255.0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -212,7 +212,7 @@ levels_adjust_by_colors (Levels *levels,
|
|||
return;
|
||||
|
||||
/* Map selected color to corresponding lightness */
|
||||
levels->gamma[channel] = log (inten) / log (out_light);
|
||||
levels->gamma[channel] = log (inten) / log (out_light);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -259,32 +259,36 @@ levels_lut_func (Levels *levels,
|
|||
gdouble inten;
|
||||
gint j;
|
||||
|
||||
if (n_channels == 1)
|
||||
j = 0;
|
||||
if (n_channels <= 2)
|
||||
j = channel;
|
||||
else
|
||||
j = channel + 1;
|
||||
|
||||
inten = value;
|
||||
|
||||
/* For color images this runs through the loop with j = channel +1
|
||||
/* For RGB and RGBA images this runs through the loop with j = channel + 1
|
||||
* the first time and j = 0 the second time
|
||||
*
|
||||
* For bw images this runs through the loop with j = 0 the first and
|
||||
* only time
|
||||
* For GRAY images this runs through the loop with j = 0 the first and
|
||||
* only time
|
||||
*/
|
||||
for (; j >= 0; j -= (channel + 1))
|
||||
{
|
||||
/* don't apply the overall curve to the alpha channel */
|
||||
if (j == 0 && (n_channels == 2 || n_channels == 4)
|
||||
&& channel == n_channels -1)
|
||||
if (j == 0 && (n_channels == 2 || n_channels == 4) &&
|
||||
channel == n_channels - 1)
|
||||
return inten;
|
||||
|
||||
/* determine input intensity */
|
||||
if (levels->high_input[j] != levels->low_input[j])
|
||||
inten = ((gdouble) (255.0 * inten - levels->low_input[j]) /
|
||||
(gdouble) (levels->high_input[j] - levels->low_input[j]));
|
||||
{
|
||||
inten = ((gdouble) (255.0 * inten - levels->low_input[j]) /
|
||||
(gdouble) (levels->high_input[j] - levels->low_input[j]));
|
||||
}
|
||||
else
|
||||
inten = (gdouble) (255.0 * inten - levels->low_input[j]);
|
||||
{
|
||||
inten = (gdouble) (255.0 * inten - levels->low_input[j]);
|
||||
}
|
||||
|
||||
if (levels->gamma[j] != 0.0)
|
||||
{
|
||||
|
|
|
@ -233,8 +233,8 @@ levels_invoker (Gimp *gimp,
|
|||
if (success)
|
||||
{
|
||||
/* FIXME: hack */
|
||||
if (gimp_drawable_is_gray (drawable) && gimp_drawable_has_alpha (drawable))
|
||||
channel = (channel > 1) ? 2 : 1;
|
||||
if (gimp_drawable_is_gray (drawable) && channel == GIMP_HISTOGRAM_ALPHA)
|
||||
channel = 1;
|
||||
|
||||
lut = gimp_lut_new ();
|
||||
|
||||
|
@ -694,8 +694,8 @@ curves_spline_invoker (Gimp *gimp,
|
|||
if (success)
|
||||
{
|
||||
/* FIXME: hack */
|
||||
if (gimp_drawable_is_gray (drawable) && gimp_drawable_has_alpha (drawable))
|
||||
channel = (channel > 1) ? 2 : 1;
|
||||
if (gimp_drawable_is_gray (drawable) && channel == GIMP_HISTOGRAM_ALPHA)
|
||||
channel = 1;
|
||||
|
||||
lut = gimp_lut_new ();
|
||||
|
||||
|
@ -817,8 +817,8 @@ curves_explicit_invoker (Gimp *gimp,
|
|||
if (success)
|
||||
{
|
||||
/* FIXME: hack */
|
||||
if (gimp_drawable_is_gray (drawable) && gimp_drawable_has_alpha (drawable))
|
||||
channel = (channel > 1) ? 2 : 1;
|
||||
if (gimp_drawable_is_gray (drawable) && channel == GIMP_HISTOGRAM_ALPHA)
|
||||
channel = 1;
|
||||
|
||||
lut = gimp_lut_new ();
|
||||
|
||||
|
|
|
@ -311,8 +311,9 @@ gimp_curves_tool_initialize (GimpTool *tool,
|
|||
gimp_int_combo_box_set_active (GIMP_INT_COMBO_BOX (c_tool->channel_menu),
|
||||
c_tool->channel);
|
||||
|
||||
if (! c_tool->color && c_tool->alpha)
|
||||
c_tool->channel = 1;
|
||||
/* FIXME: hack */
|
||||
if (! c_tool->color)
|
||||
c_tool->channel = (c_tool->channel == GIMP_HISTOGRAM_ALPHA) ? 1 : 0;
|
||||
|
||||
gimp_drawable_calculate_histogram (drawable, c_tool->hist);
|
||||
gimp_histogram_view_set_histogram (GIMP_HISTOGRAM_VIEW (c_tool->graph),
|
||||
|
@ -362,11 +363,10 @@ gimp_curves_tool_color_picked (GimpColorTool *color_tool,
|
|||
GimpRGB *color,
|
||||
gint color_index)
|
||||
{
|
||||
GimpCurvesTool *tool;
|
||||
GimpCurvesTool *tool = GIMP_CURVES_TOOL (color_tool);
|
||||
GimpDrawable *drawable;
|
||||
guchar r, g, b, a;
|
||||
|
||||
tool = GIMP_CURVES_TOOL (color_tool);
|
||||
drawable = GIMP_IMAGE_MAP_TOOL (tool)->drawable;
|
||||
|
||||
gimp_rgba_get_uchar (color, &r, &g, &b, &a);
|
||||
|
@ -756,7 +756,8 @@ curves_update (GimpCurvesTool *tool,
|
|||
}
|
||||
else
|
||||
{
|
||||
if (tool->channel == 2)
|
||||
/* FIXME: hack */
|
||||
if (tool->channel == 1)
|
||||
channel = GIMP_HISTOGRAM_ALPHA;
|
||||
else
|
||||
channel = GIMP_HISTOGRAM_VALUE;
|
||||
|
@ -772,9 +773,9 @@ curves_update (GimpCurvesTool *tool,
|
|||
case GIMP_HISTOGRAM_VALUE:
|
||||
case GIMP_HISTOGRAM_ALPHA:
|
||||
gimp_color_bar_set_buffers (GIMP_COLOR_BAR (tool->xrange),
|
||||
tool->curves->curve[channel],
|
||||
tool->curves->curve[channel],
|
||||
tool->curves->curve[channel]);
|
||||
tool->curves->curve[tool->channel],
|
||||
tool->curves->curve[tool->channel],
|
||||
tool->curves->curve[tool->channel]);
|
||||
break;
|
||||
|
||||
case GIMP_HISTOGRAM_RED:
|
||||
|
@ -804,8 +805,8 @@ curves_channel_callback (GtkWidget *widget,
|
|||
tool->channel);
|
||||
|
||||
/* FIXME: hack */
|
||||
if (! tool->color && tool->alpha)
|
||||
tool->channel = (tool->channel > 1) ? 2 : 1;
|
||||
if (! tool->color)
|
||||
tool->channel = (tool->channel == GIMP_HISTOGRAM_ALPHA) ? 1 : 0;
|
||||
|
||||
gimp_int_radio_group_set_active (GTK_RADIO_BUTTON (tool->curve_type),
|
||||
tool->curves->curve_type[tool->channel]);
|
||||
|
@ -1163,7 +1164,8 @@ curves_graph_expose (GtkWidget *widget,
|
|||
}
|
||||
else
|
||||
{
|
||||
if (tool->channel == 2)
|
||||
/* FIXME: hack */
|
||||
if (tool->channel == 1)
|
||||
channel = GIMP_HISTOGRAM_ALPHA;
|
||||
else
|
||||
channel = GIMP_HISTOGRAM_VALUE;
|
||||
|
|
|
@ -308,8 +308,9 @@ gimp_levels_tool_initialize (GimpTool *tool,
|
|||
gimp_int_combo_box_set_active (GIMP_INT_COMBO_BOX (l_tool->channel_menu),
|
||||
l_tool->channel);
|
||||
|
||||
if (! l_tool->color && l_tool->alpha)
|
||||
l_tool->channel = 1;
|
||||
/* FIXME: hack */
|
||||
if (! l_tool->color)
|
||||
l_tool->channel = (l_tool->channel == GIMP_HISTOGRAM_ALPHA) ? 1 : 0;
|
||||
|
||||
levels_update (l_tool, ALL);
|
||||
|
||||
|
@ -825,7 +826,8 @@ levels_update (GimpLevelsTool *tool,
|
|||
}
|
||||
else
|
||||
{
|
||||
if (tool->channel == 2)
|
||||
/* FIXME: hack */
|
||||
if (tool->channel == 1)
|
||||
channel = GIMP_HISTOGRAM_ALPHA;
|
||||
else
|
||||
channel = GIMP_HISTOGRAM_VALUE;
|
||||
|
@ -868,9 +870,9 @@ levels_update (GimpLevelsTool *tool,
|
|||
case GIMP_HISTOGRAM_VALUE:
|
||||
case GIMP_HISTOGRAM_ALPHA:
|
||||
gimp_color_bar_set_buffers (GIMP_COLOR_BAR (tool->input_bar),
|
||||
tool->levels->input[channel],
|
||||
tool->levels->input[channel],
|
||||
tool->levels->input[channel]);
|
||||
tool->levels->input[tool->channel],
|
||||
tool->levels->input[tool->channel],
|
||||
tool->levels->input[tool->channel]);
|
||||
break;
|
||||
|
||||
case GIMP_HISTOGRAM_RED:
|
||||
|
@ -911,8 +913,8 @@ levels_channel_callback (GtkWidget *widget,
|
|||
tool->channel);
|
||||
|
||||
/* FIXME: hack */
|
||||
if (! tool->color && tool->alpha)
|
||||
tool->channel = (tool->channel > 1) ? 2 : 1;
|
||||
if (! tool->color)
|
||||
tool->channel = (tool->channel == GIMP_HISTOGRAM_ALPHA) ? 1 : 0;
|
||||
|
||||
levels_update (tool, ALL);
|
||||
}
|
||||
|
|
|
@ -134,8 +134,8 @@ HELP
|
|||
if (success)
|
||||
{
|
||||
/* FIXME: hack */
|
||||
if (gimp_drawable_is_gray (drawable) && gimp_drawable_has_alpha (drawable))
|
||||
channel = (channel > 1) ? 2 : 1;
|
||||
if (gimp_drawable_is_gray (drawable) && channel == GIMP_HISTOGRAM_ALPHA)
|
||||
channel = 1;
|
||||
|
||||
lut = gimp_lut_new ();
|
||||
|
||||
|
@ -425,8 +425,8 @@ HELP
|
|||
if (success)
|
||||
{
|
||||
/* FIXME: hack */
|
||||
if (gimp_drawable_is_gray (drawable) && gimp_drawable_has_alpha (drawable))
|
||||
channel = (channel > 1) ? 2 : 1;
|
||||
if (gimp_drawable_is_gray (drawable) && channel == GIMP_HISTOGRAM_ALPHA)
|
||||
channel = 1;
|
||||
|
||||
lut = gimp_lut_new ();
|
||||
|
||||
|
@ -506,8 +506,8 @@ HELP
|
|||
if (success)
|
||||
{
|
||||
/* FIXME: hack */
|
||||
if (gimp_drawable_is_gray (drawable) && gimp_drawable_has_alpha (drawable))
|
||||
channel = (channel > 1) ? 2 : 1;
|
||||
if (gimp_drawable_is_gray (drawable) && channel == GIMP_HISTOGRAM_ALPHA)
|
||||
channel = 1;
|
||||
|
||||
lut = gimp_lut_new ();
|
||||
|
||||
|
|
Loading…
Reference in a new issue