diff options
author | Tor Andersson <tor@ghostscript.com> | 2010-06-23 15:07:18 +0200 |
---|---|---|
committer | Tor Andersson <tor@ghostscript.com> | 2010-06-23 15:07:18 +0200 |
commit | dccc859e937cedd63e5b6450f65a4d91786b5332 (patch) | |
tree | 1e409c37d4b08e367249fb0eda7164730cd959c4 | |
parent | 25a767ac1be90d132ecb30f720bf5c5c248fc9e0 (diff) | |
download | mupdf-dccc859e937cedd63e5b6450f65a4d91786b5332.tar.xz |
Add special case loops for loadtile8 when pad is 1 and 3 (grayscale and rgb).
-rw-r--r-- | Makethird | 2 | ||||
-rw-r--r-- | draw/imageunpack.c | 73 |
2 files changed, 73 insertions, 2 deletions
@@ -88,7 +88,7 @@ ZLIB_SRC=$(addprefix $(zlib_dir)/, \ ZLIB_OBJ=$(ZLIB_SRC:$(zlib_dir)/%.c=$(OBJDIR)/zlib_%.o) ZLIB_LIB=$(OBJDIR)/libz.a $(ZLIB_LIB): $(ZLIB_OBJ) - $(AR_CMD) + $(AR_CMD) $(OBJDIR)/zlib_%.o: $(zlib_dir)/%.c $(CC_CMD) diff --git a/draw/imageunpack.c b/draw/imageunpack.c index 4e876092..6a1a1628 100644 --- a/draw/imageunpack.c +++ b/draw/imageunpack.c @@ -224,7 +224,78 @@ TILE(ttwo) static void loadtile4(byte * restrict src, int sw, byte * restrict dst, int dw, int w, int h, int pad) TILE(tnib) static void loadtile8(byte * restrict src, int sw, byte * restrict dst, int dw, int w, int h, int pad) -TILE(toct) +{ + if ((h == 0) || (w == 0)) + return; + + switch (pad) + { + case 0: + while (h--) + { + memcpy(dst, src, w); + src += sw; + dst += dw; + } + break; + + case 1: + sw -= w; + dw -= w<<1; + while (h--) + { + int x; + for (x = w; x > 0; x --) + { + *dst++ = 255; + *dst++ = *src++; + } + src += sw; + dst += dw; + } + break; + + case 3: + sw -= w; + while (h--) + { + byte *dp = dst; + int x; + for (x = w; x > 0; x -= 3) + { + *dp++ = 255; + *dp++ = *src++; + *dp++ = *src++; + *dp++ = *src++; + } + src += sw; + dst += dw; + } + break; + + default: + sw -= w; + while (h--) + { + byte *dp = dst; + int tpad = 1; + int x; + for (x = w; x > 0; x--) + { + tpad--; + if (tpad == 0) { + tpad = pad; + *dp++ = 255; + } + *dp++ = *src++; + } + src += sw; + dst += dw; + } + break; + } +} + static void loadtile16(byte * restrict src, int sw, byte * restrict dst, int dw, int w, int h, int pad) TILE(thex) |