diff options
author | Tor Andersson <tor@ghostscript.com> | 2010-12-16 20:50:05 +0000 |
---|---|---|
committer | Tor Andersson <tor@ghostscript.com> | 2010-12-16 20:50:05 +0000 |
commit | ed530d4435b0840630f58506d7d7c5970522e88b (patch) | |
tree | 58f73c8affe0f33fb66059a2b5f5272fc3b4dd4f | |
parent | 2033c2c989f90bbe33e9cff7aa4ddeeb7dec0398 (diff) | |
download | mupdf-ed530d4435b0840630f58506d7d7c5970522e88b.tar.xz |
Fix loading sampled function with bit depths 2 and 4.
-rw-r--r-- | mupdf/pdf_function.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/mupdf/pdf_function.c b/mupdf/pdf_function.c index f937963f..2a248f46 100644 --- a/mupdf/pdf_function.c +++ b/mupdf/pdf_function.c @@ -1065,19 +1065,19 @@ loadsamplefunc(pdf_function *func, pdf_xref *xref, fz_obj *dict, int num, int ge if (bps == 1) { int x = fz_peekbyte(stream); - s = (x >> (7 - (i & 0x7))) & 0x01; + s = (x >> ( 7 - (i & 7) ) ) & 1; if ((i & 0x07) == 7) fz_readbyte(stream); } else if (bps == 2) { int x = fz_peekbyte(stream); - s = ((x >> (3 - (i & 0x3))) & 0x03) / 4.0f; + s = ((x >> ( ( 3 - (i & 3) ) << 1 ) ) & 3 ) / 3.0f; if ((i & 0x3) == 3) fz_readbyte(stream); } else if (bps == 4) { int x = fz_peekbyte(stream); - s = ((x >> (1 - (i & 0x1))) & 0x0f) / 16.0f; + s = ((x >> ( ( 1 - (i & 1) ) << 2 ) ) & 15 ) / 15.0f; if ((i & 0x1) == 1) fz_readbyte(stream); } @@ -1094,7 +1094,7 @@ loadsamplefunc(pdf_function *func, pdf_xref *xref, fz_obj *dict, int num, int ge unsigned int x = fz_readbyte(stream); x = (x << 8) + fz_readbyte(stream); x = (x << 8) + fz_readbyte(stream); - s = x / 16777216.0f; + s = x / 16777215.0f; } else if (bps == 32) { unsigned int x = fz_readbyte(stream); |