Fix for the colour balance filter on systems with signed chars.

Added function rgb_to_l for use when we just need the luminosity.
This commit is contained in:
Tor Lillqvist 1999-02-14 23:12:11 +00:00
parent f12faae82a
commit 32fb2d1f72
9 changed files with 103 additions and 14 deletions

View File

@ -1,3 +1,12 @@
Sun Feb 14 22:16:16 1999 Tor Lillqvist <tml@iki.fi>
* app/paint_funcs.c app/paint_funcs.h : New function rgb_to_l for
when we only want the luminosity. (rgb_to_hls): Use "else if" for
case which can't be true if previous test succeeded.
* app/color_balance.c (struct _ColorBalanceDialog): use
lookup tables with unsigned values for the RGB components.
Sun Feb 14 23:27:57 CET 1999 Marc Lehmann <pcg@goof.com>
* docs/parasites.txt: Added some suggestions from Jay Cox.

View File

@ -71,9 +71,9 @@ struct _ColorBalanceDialog
double magenta_green[3];
double yellow_blue[3];
char r_lookup[255];
char g_lookup[255];
char b_lookup[255];
guchar r_lookup[255];
guchar g_lookup[255];
guchar b_lookup[255];
gint preserve_luminosity;
gint preview;

View File

@ -71,9 +71,9 @@ struct _ColorBalanceDialog
double magenta_green[3];
double yellow_blue[3];
char r_lookup[255];
char g_lookup[255];
char b_lookup[255];
guchar r_lookup[255];
guchar g_lookup[255];
guchar b_lookup[255];
gint preserve_luminosity;
gint preview;

View File

@ -5327,7 +5327,7 @@ rgb_to_hls (int *r,
if (h < 0)
h += 255;
if (h > 255)
else if (h > 255)
h -= 255;
}
@ -5337,6 +5337,45 @@ rgb_to_hls (int *r,
}
/* Just compute the luminosity component. */
int
rgb_to_l (int red,
int green,
int blue)
{
float h, l, s;
int min, max;
int delta;
if (red > green)
{
if (red > blue)
max = red;
else
max = blue;
if (green < blue)
min = green;
else
min = blue;
}
else
{
if (green > blue)
max = green;
else
max = blue;
if (red < blue)
min = red;
else
min = blue;
}
return (max + min) / 2.0;
}
static int
hls_value (float n1,
float n2,

View File

@ -571,6 +571,7 @@ void combine_regions_replace (PixelRegion *, PixelRegion *,
void rgb_to_hsv (int *, int *, int *);
void hsv_to_rgb (int *, int *, int *);
void rgb_to_hls (int *, int *, int *);
int rgb_to_l (int, int, int);
void hls_to_rgb (int *, int *, int *);
/* Opacities */

View File

@ -5327,7 +5327,7 @@ rgb_to_hls (int *r,
if (h < 0)
h += 255;
if (h > 255)
else if (h > 255)
h -= 255;
}
@ -5337,6 +5337,45 @@ rgb_to_hls (int *r,
}
/* Just compute the luminosity component. */
int
rgb_to_l (int red,
int green,
int blue)
{
float h, l, s;
int min, max;
int delta;
if (red > green)
{
if (red > blue)
max = red;
else
max = blue;
if (green < blue)
min = green;
else
min = blue;
}
else
{
if (green > blue)
max = green;
else
max = blue;
if (red < blue)
min = red;
else
min = blue;
}
return (max + min) / 2.0;
}
static int
hls_value (float n1,
float n2,

View File

@ -571,6 +571,7 @@ void combine_regions_replace (PixelRegion *, PixelRegion *,
void rgb_to_hsv (int *, int *, int *);
void hsv_to_rgb (int *, int *, int *);
void rgb_to_hls (int *, int *, int *);
int rgb_to_l (int, int, int);
void hls_to_rgb (int *, int *, int *);
/* Opacities */

View File

@ -71,9 +71,9 @@ struct _ColorBalanceDialog
double magenta_green[3];
double yellow_blue[3];
char r_lookup[255];
char g_lookup[255];
char b_lookup[255];
guchar r_lookup[255];
guchar g_lookup[255];
guchar b_lookup[255];
gint preserve_luminosity;
gint preview;

View File

@ -71,9 +71,9 @@ struct _ColorBalanceDialog
double magenta_green[3];
double yellow_blue[3];
char r_lookup[255];
char g_lookup[255];
char b_lookup[255];
guchar r_lookup[255];
guchar g_lookup[255];
guchar b_lookup[255];
gint preserve_luminosity;
gint preview;