diff options
author | Tor Andersson <tor@ghostscript.com> | 2010-07-10 21:08:52 +0200 |
---|---|---|
committer | Tor Andersson <tor@ghostscript.com> | 2010-07-10 21:08:52 +0200 |
commit | a8a47bb3f214467016d2b37d95e98ffdec4f7ba1 (patch) | |
tree | 616430e11d8d66b397572ff982c899f63e25a2a4 /draw | |
parent | 47dd54d16a6132b14103fbc146970d22172f07c3 (diff) | |
download | mupdf-a8a47bb3f214467016d2b37d95e98ffdec4f7ba1.tar.xz |
Refactor colorspace and PDF image parsing code.
Diffstat (limited to 'draw')
-rw-r--r-- | draw/imageunpack.c | 27 |
1 files changed, 12 insertions, 15 deletions
diff --git a/draw/imageunpack.c b/draw/imageunpack.c index 25a21770..6e5467ad 100644 --- a/draw/imageunpack.c +++ b/draw/imageunpack.c @@ -6,7 +6,7 @@ typedef unsigned char byte; * Apply decode parameters */ -static void decodetile(fz_pixmap *pix, int skip, float *decode) +static void decodetile(fz_pixmap *pix, int imagemask, float *decode) { int min[FZ_MAXCOLORS]; int max[FZ_MAXCOLORS]; @@ -17,9 +17,8 @@ static void decodetile(fz_pixmap *pix, int skip, float *decode) int wh = pix->w * pix->h; int i; int justinvert = 1; - unsigned int mask; - for (i = 0; i < n-skip; i++) + for (i = 0; i < n - imagemask; i++) { min[i] = decode[i * 2] * 255; max[i] = decode[i * 2 + 1] * 255; @@ -28,18 +27,13 @@ static void decodetile(fz_pixmap *pix, int skip, float *decode) justinvert &= min[i] == 255 && max[i] == 0 && sub[i] == -255; } - if (skip) + if (imagemask) { min[i] = 0; max[i] = 255; sub[i] = 255; } - if (fz_isbigendian()) - mask = 0x00ff00ff; - else - mask = 0xff00ff00; - if (!needed) return; @@ -52,9 +46,10 @@ static void decodetile(fz_pixmap *pix, int skip, float *decode) } break; case 2: - if (justinvert) { + if (justinvert) + { + unsigned mask = fz_isbigendian() ? 0x00ff00ff : 0xff00ff00; unsigned *wp = (unsigned *)p; - if ((((char *)wp - (char *)0) & 3) == 0) { int hwh = wh / 2; wh = wh - 2 * hwh; @@ -72,11 +67,13 @@ static void decodetile(fz_pixmap *pix, int skip, float *decode) } } else - while (wh--) { - p[0] = min[0] + fz_mul255(sub[0], p[0]); - p[1] = min[1] + fz_mul255(sub[1], p[1]); - p += 2; + while (wh--) + { + p[0] = min[0] + fz_mul255(sub[0], p[0]); + p[1] = min[1] + fz_mul255(sub[1], p[1]); + p += 2; + } } break; default: |