diff options
author | Tor Andersson <tor@ghostscript.com> | 2010-12-05 00:34:36 +0000 |
---|---|---|
committer | Tor Andersson <tor@ghostscript.com> | 2010-12-05 00:34:36 +0000 |
commit | 90803bae04906143cb650688970878af92486ef4 (patch) | |
tree | 25e5d8b3df18515e62cfdd6ab5a5580d071c2b8d | |
parent | 7940cee7f4ecfa7cca755396a235615bdbbee2d7 (diff) | |
download | mupdf-90803bae04906143cb650688970878af92486ef4.tar.xz |
Support N-d sampled functions with nearest neighbor sampling.
-rw-r--r-- | mupdf/pdf_function.c | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/mupdf/pdf_function.c b/mupdf/pdf_function.c index 869f10d0..3e3be3f7 100644 --- a/mupdf/pdf_function.c +++ b/mupdf/pdf_function.c @@ -1105,7 +1105,7 @@ evalsamplefunc(pdf_function *func, float *in, float *out) int e0[MAXM], e1[MAXM]; float efrac[MAXM]; float x; - int i; + int i, k; /* encode input coordinates */ for (i = 0; i < func->m; i++) @@ -1182,7 +1182,20 @@ evalsamplefunc(pdf_function *func, float *in, float *out) else { - return fz_throw("sampled %d-d functions not implemented", func->m); + int idx = 0; + int scale = func->n; + float x; + + for (k = 0; k < func->m; k++) + { + idx = idx + e0[k] * scale; + scale = scale * func->u.sa.size[k]; + } + + x = func->u.sa.samples[idx + i]; + + out[i] = LERP(x, 0, 1, func->u.sa.decode[i][0], func->u.sa.decode[i][1]); + out[i] = CLAMP(out[i], func->range[i][0], func->range[i][1]); } } |