diff --git a/ChangeLog b/ChangeLog index 69cc60b22a..683df568a7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +Sun Feb 14 22:16:16 1999 Tor Lillqvist + + * 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 * docs/parasites.txt: Added some suggestions from Jay Cox. diff --git a/app/base/color-balance.c b/app/base/color-balance.c index 125a20c402..6aaf361e57 100644 --- a/app/base/color-balance.c +++ b/app/base/color-balance.c @@ -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; diff --git a/app/color_balance.c b/app/color_balance.c index 125a20c402..6aaf361e57 100644 --- a/app/color_balance.c +++ b/app/color_balance.c @@ -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; diff --git a/app/paint-funcs/paint-funcs.c b/app/paint-funcs/paint-funcs.c index ca379a47b7..2e7d61bf88 100644 --- a/app/paint-funcs/paint-funcs.c +++ b/app/paint-funcs/paint-funcs.c @@ -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, diff --git a/app/paint-funcs/paint-funcs.h b/app/paint-funcs/paint-funcs.h index 61f97a2624..4357a63c91 100644 --- a/app/paint-funcs/paint-funcs.h +++ b/app/paint-funcs/paint-funcs.h @@ -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 */ diff --git a/app/paint_funcs.c b/app/paint_funcs.c index ca379a47b7..2e7d61bf88 100644 --- a/app/paint_funcs.c +++ b/app/paint_funcs.c @@ -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, diff --git a/app/paint_funcs.h b/app/paint_funcs.h index 61f97a2624..4357a63c91 100644 --- a/app/paint_funcs.h +++ b/app/paint_funcs.h @@ -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 */ diff --git a/app/tools/color_balance.c b/app/tools/color_balance.c index 125a20c402..6aaf361e57 100644 --- a/app/tools/color_balance.c +++ b/app/tools/color_balance.c @@ -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; diff --git a/app/tools/gimpcolorbalancetool.c b/app/tools/gimpcolorbalancetool.c index 125a20c402..6aaf361e57 100644 --- a/app/tools/gimpcolorbalancetool.c +++ b/app/tools/gimpcolorbalancetool.c @@ -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;