diff options
author | Robin Watts <robin.watts@artifex.com> | 2012-01-06 12:06:24 +0000 |
---|---|---|
committer | Robin Watts <robin@ghostscript.com> | 2012-01-06 13:49:24 +0000 |
commit | 9bda8c7e42724ab709cc1552a1e79a181ccb3fc5 (patch) | |
tree | 69e20060665bb13e7a418d31a9d789c367cc31c9 /draw | |
parent | 8148a49342243c4a4dfd2aece347a45606cdac00 (diff) | |
download | mupdf-9bda8c7e42724ab709cc1552a1e79a181ccb3fc5.tar.xz |
Clamp pixel values after applying Decode array to images.
Thanks to Zeniko for pointing this out.
Diffstat (limited to 'draw')
-rw-r--r-- | draw/draw_unpack.c | 10 |
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; } } |