mirror of
https://gitlab.gnome.org/GNOME/gimp
synced 2024-10-21 20:12:30 +00:00
change the LUT function for the contrast. Fixes the buggy behaviour as
2006-02-24 Simon Budig <simon@gimp.org> * app/base/lut-funcs.c: change the LUT function for the contrast. Fixes the buggy behaviour as described in bug #319872 and bug #332068 and makes the behaviour consistent with the standard contrast formula. However, I am leaving the bug open to discuss further improvements. Untabbified.
This commit is contained in:
parent
3343baa84c
commit
78c41aa68f
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
|||
2006-02-24 Simon Budig <simon@gimp.org>
|
||||
|
||||
* app/base/lut-funcs.c: change the LUT function for the contrast.
|
||||
Fixes the buggy behaviour as described in bug #319872 and
|
||||
bug #332068 and makes the behaviour consistent with the standard
|
||||
contrast formula. However, I am leaving the bug open to discuss
|
||||
further improvements.
|
||||
|
||||
Untabbified.
|
||||
|
||||
2006-02-23 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* libgimpbase/gimpwire.[ch]: added utility functions to send
|
||||
|
|
|
@ -43,8 +43,7 @@ brightness_contrast_lut_func (B_C_struct *data,
|
|||
gint channel,
|
||||
gfloat value)
|
||||
{
|
||||
gfloat nvalue;
|
||||
gdouble power;
|
||||
gdouble slant;
|
||||
|
||||
/* return the original value for the alpha channel */
|
||||
if ((nchannels == 2 || nchannels == 4) && channel == nchannels -1)
|
||||
|
@ -56,42 +55,8 @@ brightness_contrast_lut_func (B_C_struct *data,
|
|||
else
|
||||
value = value + ((1.0 - value) * data->brightness);
|
||||
|
||||
/* apply contrast */
|
||||
if (data->contrast < 0.0)
|
||||
{
|
||||
if (value > 0.5)
|
||||
nvalue = 1.0 - value;
|
||||
else
|
||||
nvalue = value;
|
||||
|
||||
if (nvalue < 0.0)
|
||||
nvalue = 0.0;
|
||||
|
||||
nvalue = 0.5 * pow (nvalue * 2.0 , (double) (1.0 + data->contrast));
|
||||
|
||||
if (value > 0.5)
|
||||
value = 1.0 - nvalue;
|
||||
else
|
||||
value = nvalue;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (value > 0.5)
|
||||
nvalue = 1.0 - value;
|
||||
else
|
||||
nvalue = value;
|
||||
|
||||
if (nvalue < 0.0)
|
||||
nvalue = 0.0;
|
||||
|
||||
power = (data->contrast == 1.0) ? 127 : 1.0 / (1.0 - data->contrast);
|
||||
nvalue = 0.5 * pow (2.0 * nvalue, power);
|
||||
|
||||
if (value > 0.5)
|
||||
value = 1.0 - nvalue;
|
||||
else
|
||||
value = nvalue;
|
||||
}
|
||||
slant = tan ((data->contrast + 1) * G_PI_4);
|
||||
value = (value - 0.5) * slant + 0.5;
|
||||
|
||||
return value;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue