Commit 32fb2d1f authored by Tor Lillqvist's avatar Tor Lillqvist
Browse files

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

Added function rgb_to_l for use when we just need the luminosity.
parent f12faae8
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.
......
......@@ -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;
......
......@@ -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;
......
......@@ -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,
......
......@@ -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 */
......
......@@ -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,
......
......@@ -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 */
......
......@@ -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;
......
......@@ -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;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment