mirror of https://github.com/GNOME/gimp.git
fix the brightness/contrast --> levels step by doing proper math (TM).
2008-09-18 Simon Budig <simon@gimp.org> * app/gegl/gimpbrightnesscontrastconfig.c: fix the brightness/contrast --> levels step by doing proper math (TM). svn path=/trunk/; revision=26984
This commit is contained in:
parent
cd4dd6c5b6
commit
53385418fb
|
@ -1,3 +1,8 @@
|
|||
2008-09-18 Simon Budig <simon@gimp.org>
|
||||
|
||||
* app/gegl/gimpbrightnesscontrastconfig.c: fix the
|
||||
brightness/contrast --> levels step by doing proper math (TM).
|
||||
|
||||
2008-09-18 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* tools/pdbgen/pdb/drawable.pdb: gimp_drawable_mask_intersect()
|
||||
|
|
|
@ -162,7 +162,7 @@ gimp_brightness_contrast_config_to_levels_config (GimpBrightnessContrastConfig *
|
|||
{
|
||||
GimpLevelsConfig *levels;
|
||||
gdouble brightness;
|
||||
gdouble contrast;
|
||||
gdouble slant;
|
||||
gdouble value;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_BRIGHTNESS_CONTRAST_CONFIG (config), NULL);
|
||||
|
@ -170,33 +170,63 @@ gimp_brightness_contrast_config_to_levels_config (GimpBrightnessContrastConfig *
|
|||
levels = g_object_new (GIMP_TYPE_LEVELS_CONFIG, NULL);
|
||||
|
||||
brightness = config->brightness / 2.0;
|
||||
contrast = (config->contrast < 0 ?
|
||||
(config->contrast + 1.0) :
|
||||
config->contrast * 4.0 + 1.0);
|
||||
slant = tan ((config->contrast + 1) * G_PI_4);
|
||||
|
||||
value = -0.5 * contrast + brightness + 0.5;
|
||||
|
||||
if (value < 0.0)
|
||||
if (config->brightness >= 0)
|
||||
{
|
||||
value = 0.0;
|
||||
value = -0.5 * slant + brightness * slant + 0.5;
|
||||
|
||||
levels->low_input[GIMP_HISTOGRAM_VALUE] =
|
||||
(-0.5 - brightness) / contrast + 0.5;
|
||||
if (value < 0.0)
|
||||
{
|
||||
value = 0.0;
|
||||
|
||||
/* this slightly convoluted math follows by inverting the
|
||||
* calculation of the brightness/contrast LUT in base/lut-funcs.h */
|
||||
|
||||
levels->low_input[GIMP_HISTOGRAM_VALUE] =
|
||||
(brightness * slant + 0.5 * slant - 0.5) / (slant - brightness * slant);
|
||||
}
|
||||
|
||||
levels->low_output[GIMP_HISTOGRAM_VALUE] = value;
|
||||
|
||||
value = 0.5 * slant + 0.5;
|
||||
|
||||
if (value > 1.0)
|
||||
{
|
||||
value = 1.0;
|
||||
|
||||
levels->high_input[GIMP_HISTOGRAM_VALUE] =
|
||||
(brightness * slant + 0.5 * slant + 0.5) / (slant - brightness * slant);
|
||||
}
|
||||
|
||||
levels->high_output[GIMP_HISTOGRAM_VALUE] = value;
|
||||
}
|
||||
|
||||
levels->low_output[GIMP_HISTOGRAM_VALUE] = value;
|
||||
|
||||
value = 0.5 * contrast + brightness + 0.5;
|
||||
|
||||
if (value > 1.0)
|
||||
else
|
||||
{
|
||||
value = 1.0;
|
||||
value = 0.5 - 0.5 * slant;
|
||||
|
||||
levels->high_input[GIMP_HISTOGRAM_VALUE] =
|
||||
(0.5 - brightness) / contrast + 0.5;
|
||||
if (value < 0.0)
|
||||
{
|
||||
value = 0.0;
|
||||
|
||||
levels->low_input[GIMP_HISTOGRAM_VALUE] =
|
||||
(0.5 * slant - 0.5) / (slant + brightness * slant);
|
||||
}
|
||||
|
||||
levels->low_output[GIMP_HISTOGRAM_VALUE] = value;
|
||||
|
||||
value = slant * brightness + slant * 0.5 + 0.5;
|
||||
|
||||
if (value > 1.0)
|
||||
{
|
||||
value = 1.0;
|
||||
|
||||
levels->high_input[GIMP_HISTOGRAM_VALUE] =
|
||||
(0.5 * slant + 0.5) / (slant + brightness * slant);
|
||||
}
|
||||
|
||||
levels->high_output[GIMP_HISTOGRAM_VALUE] = value;
|
||||
}
|
||||
|
||||
levels->high_output[GIMP_HISTOGRAM_VALUE] = value;
|
||||
|
||||
return levels;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue