summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--draw/draw_unpack.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/draw/draw_unpack.c b/draw/draw_unpack.c
index b60de3b8..6da5e8a3 100644
--- a/draw/draw_unpack.c
+++ b/draw/draw_unpack.c
@@ -197,7 +197,10 @@ fz_decode_indexed_tile(fz_pixmap *pix, float *decode, int maxval)
while (len--)
{
for (k = 0; k < n; k++)
- p[k] = (add[k] + (((p[k] << 8) * mul[k]) >> 8)) >> 8;
+ {
+ int value = (add[k] + (((p[k] << 8) * mul[k]) >> 8)) >> 8;
+ p[k] = CLAMP(value, 0, 255);
+ }
p += n + 1;
}
}
@@ -229,7 +232,10 @@ fz_decode_tile(fz_pixmap *pix, float *decode)
while (len--)
{
for (k = 0; k < n; k++)
- p[k] = add[k] + fz_mul255(p[k], mul[k]);
+ {
+ int value = add[k] + fz_mul255(p[k], mul[k]);
+ p[k] = CLAMP(value, 0, 255);
+ }
p += pix->n;
}
}