summaryrefslogtreecommitdiff
path: root/draw
diff options
context:
space:
mode:
authorTor Andersson <tor@ghostscript.com>2010-06-23 15:07:18 +0200
committerTor Andersson <tor@ghostscript.com>2010-06-23 15:07:18 +0200
commitdccc859e937cedd63e5b6450f65a4d91786b5332 (patch)
tree1e409c37d4b08e367249fb0eda7164730cd959c4 /draw
parent25a767ac1be90d132ecb30f720bf5c5c248fc9e0 (diff)
downloadmupdf-dccc859e937cedd63e5b6450f65a4d91786b5332.tar.xz
Add special case loops for loadtile8 when pad is 1 and 3 (grayscale and rgb).
Diffstat (limited to 'draw')
-rw-r--r--draw/imageunpack.c73
1 files changed, 72 insertions, 1 deletions
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)