summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Rasmussen <sebras@gmail.com>2016-07-06 11:18:38 +0800
committerSebastian Rasmussen <sebras@gmail.com>2016-09-16 18:17:15 +0800
commitdaf99a045fb45f6cc897887acd197824051787b1 (patch)
tree02329ab755a4f017690a5c809285258a0ec5cfd8
parent2b22d3bfb4579971eccfaefa09ea077ce992e9d2 (diff)
downloadmupdf-daf99a045fb45f6cc897887acd197824051787b1.tar.xz
fz_unpack_tile now skips extra input components.
This is useful when a TIFF image is grayscale but supplies more than a single component per sample.
-rw-r--r--source/fitz/draw-unpack.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/source/fitz/draw-unpack.c b/source/fitz/draw-unpack.c
index d2a0c72e..ba11cd3e 100644
--- a/source/fitz/draw-unpack.c
+++ b/source/fitz/draw-unpack.c
@@ -49,12 +49,18 @@ init_get1_tables(void)
void
fz_unpack_tile(fz_context *ctx, fz_pixmap *dst, unsigned char * restrict src, int n, int depth, size_t stride, int scale)
{
- int pad, x, y, k;
+ int pad, x, y, k, skip;
int w = dst->w;
pad = 0;
+ skip = 0;
if (dst->n > n)
pad = 255;
+ if (dst->n < n)
+ {
+ skip = n - dst->n;
+ n = dst->n;
+ }
if (depth == 1)
init_get1_tables();
@@ -76,7 +82,7 @@ fz_unpack_tile(fz_context *ctx, fz_pixmap *dst, unsigned char * restrict src, in
/* Specialized loops */
- if (n == 1 && depth == 1 && scale == 1 && !pad)
+ if (n == 1 && depth == 1 && scale == 1 && !pad && !skip)
{
int w3 = w >> 3;
for (x = 0; x < w3; x++)
@@ -89,7 +95,7 @@ fz_unpack_tile(fz_context *ctx, fz_pixmap *dst, unsigned char * restrict src, in
memcpy(dp, get1_tab_1[*sp], w - x);
}
- else if (n == 1 && depth == 1 && scale == 255 && !pad)
+ else if (n == 1 && depth == 1 && scale == 255 && !pad && !skip)
{
int w3 = w >> 3;
for (x = 0; x < w3; x++)
@@ -102,7 +108,7 @@ fz_unpack_tile(fz_context *ctx, fz_pixmap *dst, unsigned char * restrict src, in
memcpy(dp, get1_tab_255[*sp], w - x);
}
- else if (n == 1 && depth == 1 && scale == 1 && pad)
+ else if (n == 1 && depth == 1 && scale == 1 && pad && !skip)
{
int w3 = w >> 3;
for (x = 0; x < w3; x++)
@@ -115,7 +121,7 @@ fz_unpack_tile(fz_context *ctx, fz_pixmap *dst, unsigned char * restrict src, in
memcpy(dp, get1_tab_1p[*sp], (w - x) << 1);
}
- else if (n == 1 && depth == 1 && scale == 255 && pad)
+ else if (n == 1 && depth == 1 && scale == 255 && pad && !skip)
{
int w3 = w >> 3;
for (x = 0; x < w3; x++)
@@ -128,14 +134,14 @@ fz_unpack_tile(fz_context *ctx, fz_pixmap *dst, unsigned char * restrict src, in
memcpy(dp, get1_tab_255p[*sp], (w - x) << 1);
}
- else if (depth == 8 && !pad)
+ else if (depth == 8 && !pad && !skip)
{
int len = w * n;
while (len--)
*dp++ = *sp++;
}
- else if (depth == 8 && pad)
+ else if (depth == 8 && pad && !skip)
{
for (x = 0; x < w; x++)
{
@@ -162,6 +168,7 @@ fz_unpack_tile(fz_context *ctx, fz_pixmap *dst, unsigned char * restrict src, in
}
b++;
}
+ b += skip;
if (pad)
*dp++ = 255;
}