summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorMatthias Vogelgesang <matthias.vogelgesang@gmail.com>2012-10-23 15:33:19 +0200
committerMatthias Vogelgesang <matthias.vogelgesang@gmail.com>2012-10-23 15:33:19 +0200
commitf68bda1ebebcf589fdab832abfecf997b7f223a6 (patch)
tree97eb85d386872a923e28a42a64accd0896623798 /tools
parente88005e679e7d5bd713c6dc38de80b7a75798010 (diff)
downloaduca-f68bda1ebebcf589fdab832abfecf997b7f223a6.tar.gz
uca-f68bda1ebebcf589fdab832abfecf997b7f223a6.tar.bz2
uca-f68bda1ebebcf589fdab832abfecf997b7f223a6.tar.xz
uca-f68bda1ebebcf589fdab832abfecf997b7f223a6.zip
Clamp displayed values
Diffstat (limited to 'tools')
-rw-r--r--tools/gui/control.c6
1 files changed, 4 insertions, 2 deletions
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;