From 62052c0c624acdca8a1972257e780989bfac79c7 Mon Sep 17 00:00:00 2001 From: Sven Neumann Date: Thu, 27 Feb 2003 20:12:52 +0000 Subject: [PATCH] fixed gimp_rgb_intensity_uchar() which used to return 0 or 1 instead of 0 2003-02-27 Sven Neumann * libgimpcolor/gimprgb.c: fixed gimp_rgb_intensity_uchar() which used to return 0 or 1 instead of 0 to 255. Fixes bug #107202. --- ChangeLog | 5 +++++ libgimpcolor/gimprgb.c | 10 ++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 81b9d218c4..9acdba6558 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2003-02-27 Sven Neumann + + * libgimpcolor/gimprgb.c: fixed gimp_rgb_intensity_uchar() which + used to return 0 or 1 instead of 0 to 255. Fixes bug #107202. + 2003-02-27 Sven Neumann * app/core/gimpimage-undo-push.c (undo_push_layer_mask): fixed diff --git a/libgimpcolor/gimprgb.c b/libgimpcolor/gimprgb.c index 7b29a52c76..fe36653b58 100644 --- a/libgimpcolor/gimprgb.c +++ b/libgimpcolor/gimprgb.c @@ -177,11 +177,13 @@ gimp_rgb_gamma (GimpRGB *rgb, gdouble gimp_rgb_intensity (const GimpRGB *rgb) { + gdouble intensity; + g_return_val_if_fail (rgb != NULL, 0.0); - return (INTENSITY_RED * rgb->r + - INTENSITY_GREEN * rgb->g + - INTENSITY_BLUE * rgb->b); + intensity = INTENSITY (rgb->r, rgb->g, rgb->b); + + return CLAMP (intensity, 0.0, 1.0); } guchar @@ -189,7 +191,7 @@ gimp_rgb_intensity_uchar (const GimpRGB *rgb) { g_return_val_if_fail (rgb != NULL, 0); - return (CLAMP (gimp_rgb_intensity (rgb) * 255.999, 0.0, 1.0)); + return gimp_rgb_intensity (rgb) * 255.999; } void