From f68bda1ebebcf589fdab832abfecf997b7f223a6 Mon Sep 17 00:00:00 2001 From: Matthias Vogelgesang Date: Tue, 23 Oct 2012 15:33:19 +0200 Subject: Clamp displayed values --- tools/gui/control.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'tools') diff --git a/tools/gui/control.c b/tools/gui/control.c index 93398e4..f74e0f1 100644 --- a/tools/gui/control.c +++ b/tools/gui/control.c @@ -91,7 +91,8 @@ convert_grayscale_to_rgb (ThreadData *data, gpointer buffer) gint offset = y * stride * data->width; for (gint x = 0; x < data->display_width; x++, offset += stride) { - guchar val = (guchar) ((input[offset] - min) * factor); + gdouble dval = (input[offset] - min) * factor; + guchar val = (guchar) CLAMP(dval, 0.0, 255.0); output[i++] = val; output[i++] = val; @@ -106,7 +107,8 @@ convert_grayscale_to_rgb (ThreadData *data, gpointer buffer) gint offset = y * stride * data->width; for (gint x = 0; x < data->display_width; x++, offset += stride) { - guchar val = (guchar) ((input[offset] - min) * factor); + gdouble dval = (input[offset] - min) * factor; + guchar val = (guchar) CLAMP(dval, 0.0, 255.0); output[i++] = val; output[i++] = val; -- cgit v1.2.3