diff options
author | Sebastian Rasmussen <sebras@hotmail.com> | 2010-12-05 18:47:25 +0000 |
---|---|---|
committer | Sebastian Rasmussen <sebras@hotmail.com> | 2010-12-05 18:47:25 +0000 |
commit | 2e9c4a97538cb80df54871db5e96e9d97536cc23 (patch) | |
tree | 072b62146e53d1310d5326a17bad4ea3a0301582 | |
parent | 90803bae04906143cb650688970878af92486ef4 (diff) | |
download | mupdf-2e9c4a97538cb80df54871db5e96e9d97536cc23.tar.xz |
Support 1, 2 and 4 bit sampled functions.
-rw-r--r-- | mupdf/pdf_function.c | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/mupdf/pdf_function.c b/mupdf/pdf_function.c index 3e3be3f7..f937963f 100644 --- a/mupdf/pdf_function.c +++ b/mupdf/pdf_function.c @@ -1063,9 +1063,28 @@ loadsamplefunc(pdf_function *func, pdf_xref *xref, fz_obj *dict, int num, int ge return fz_throw("truncated sample stream"); } - if (bps == 8) { + if (bps == 1) { + int x = fz_peekbyte(stream); + s = (x >> (7 - (i & 0x7))) & 0x01; + if ((i & 0x07) == 7) + fz_readbyte(stream); + } + else if (bps == 2) { + int x = fz_peekbyte(stream); + s = ((x >> (3 - (i & 0x3))) & 0x03) / 4.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; + if ((i & 0x1) == 1) + fz_readbyte(stream); + } + else if (bps == 8) { s = fz_readbyte(stream) / 255.0f; } + /* 12 bit sampled function not supported yet */ else if (bps == 16) { int x = fz_readbyte(stream); x = (x << 8) + fz_readbyte(stream); |