summaryrefslogtreecommitdiff
path: root/draw
diff options
context:
space:
mode:
authorTor Andersson <tor@ghostscript.com>2010-06-16 12:29:54 +0200
committerTor Andersson <tor@ghostscript.com>2010-06-16 12:29:54 +0200
commit5795eaee9455031dead3dff50d1ab2d06c5f9915 (patch)
treebd5f9f2e8c29c4fa24c90f5f9d1ff6d25714dd2b /draw
parentef055a22a6ad0c28f57dc9f783124b51903f3106 (diff)
downloadmupdf-5795eaee9455031dead3dff50d1ab2d06c5f9915.tar.xz
Do runtime endianness test instead of relying on unreliable preprocessor macros.
Diffstat (limited to 'draw')
-rw-r--r--draw/imageunpack.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/draw/imageunpack.c b/draw/imageunpack.c
index 6e4e7f85..536e43d1 100644
--- a/draw/imageunpack.c
+++ b/draw/imageunpack.c
@@ -31,6 +31,12 @@ static void decodetile(fz_pixmap *pix, int skip, float *decode)
justinvert &= min[i] == 255 && max[i] == 0 && sub[i] == -255;
}
+ unsigned mask;
+ if (fz_isbigendian())
+ mask = 0x00ff00ff;
+ else
+ mask = 0xff00ff00;
+
if (!needed)
return;
@@ -51,11 +57,7 @@ static void decodetile(fz_pixmap *pix, int skip, float *decode)
wh = wh - 2 * hwh;
while(hwh--) {
unsigned in = *wp;
-#if BYTE_ORDER == LITTLE_ENDIAN
- unsigned out = in ^ 0xff00ff00;
-#else
- unsigned out = in ^ 0x00ff00ff;
-#endif
+ unsigned out = in ^ mask;
*wp++ = out;
}
p = (byte *)wp;