diff options
author | Robin Watts <robin.watts@artifex.com> | 2013-08-27 15:13:23 +0100 |
---|---|---|
committer | Robin Watts <robin.watts@artifex.com> | 2013-08-28 13:11:05 +0100 |
commit | 346295fb26f35e7b2fd15d94248cf42deecfd4a7 (patch) | |
tree | f4006f89aa2e5112d85c75c49a83875b875142a8 | |
parent | 9eb83b85cc1d1bde2bb4ad7e106b69415520ef8a (diff) | |
download | mupdf-346295fb26f35e7b2fd15d94248cf42deecfd4a7.tar.xz |
Fix big endian operation of paint code.
Broken in recent optimisations.
-rw-r--r-- | source/fitz/draw-paint.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/source/fitz/draw-paint.c b/source/fitz/draw-paint.c index e8110a1d..219a81eb 100644 --- a/source/fitz/draw-paint.c +++ b/source/fitz/draw-paint.c @@ -112,6 +112,12 @@ fz_paint_solid_color_2(byte * restrict dp, int w, byte *color) } } +static inline int isbigendian(void) +{ + union { int i; char c[sizeof(int)]; } u = {1}; + return u.c[0] != 1; +} + static inline void fz_paint_solid_color_4(byte * restrict dp, int w, byte *color) { @@ -119,7 +125,10 @@ fz_paint_solid_color_4(byte * restrict dp, int w, byte *color) int sa = FZ_EXPAND(color[3]); if (sa == 0) return; - rgba |= 0xFF000000; + if (isbigendian()) + rgba |= 0x000000FF; + else + rgba |= 0xFF000000; if (sa == 256) { while (w--) @@ -246,7 +255,10 @@ fz_paint_span_with_color_4(byte * restrict dp, byte * restrict mp, int w, byte * int sa = FZ_EXPAND(color[3]); if (sa == 0) return; - rgba |= 0xFF000000; + if (isbigendian()) + rgba |= 0x000000FF; + else + rgba |= 0xFF000000; mask = 0xFF00FF00; rb = rgba & (mask>>8); ga = (rgba & mask)>>8; |