Modify behaviour of levels tool to conserve lightness when using the

2003-12-26  Dave Neary  <bolsh@gimp.org>

        * app/base/levels.c: Modify behaviour of levels tool to
        conserve lightness when using the grey-point color-picker.
This commit is contained in:
Dave Neary 2003-12-26 21:28:30 +00:00 committed by David Neary
parent 18e559c173
commit ffdd5ee026
2 changed files with 20 additions and 1 deletions

View File

@ -1,3 +1,8 @@
2003-12-26 Dave Neary <bolsh@gimp.org>
* app/base/levels.c: Modify behaviour of levels tool to
conserve lightness when using the grey-point color-picker.
2003-12-26 Sven Neumann <sven@gimp.org>
* plug-ins/common/edge.c: forgot to change

View File

@ -22,6 +22,9 @@
#include "libgimpmath/gimpmath.h"
#include "libgimpcolor/gimpcolortypes.h"
#include "libgimpcolor/gimprgb.h"
#include "base-types.h"
#include "gimphistogram.h"
@ -185,6 +188,11 @@ levels_adjust_by_colors (Levels *levels,
gint input;
gint range;
gdouble inten;
gdouble out_light;
guchar lightness;
/* Calculate lightness value */
lightness = GIMP_RGB_INTENSITY (gray[0], gray[1], gray[2]);
input = levels_input_from_color (channel, gray);
@ -196,9 +204,15 @@ levels_adjust_by_colors (Levels *levels,
if (input < 0)
return;
/* Normalize input and lightness */
inten = (gdouble) input / (gdouble) range;
out_light = (gdouble) lightness/ (gdouble) range;
levels->gamma[channel] = log (inten) / log (0.5);
if (out_light <= 0)
return;
/* Map selected color to corresponding lightness */
levels->gamma[channel] = log (inten) / log (out_light);
}
}