From 346295fb26f35e7b2fd15d94248cf42deecfd4a7 Mon Sep 17 00:00:00 2001 From: Robin Watts Date: Tue, 27 Aug 2013 15:13:23 +0100 Subject: Fix big endian operation of paint code. Broken in recent optimisations. --- source/fitz/draw-paint.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'source/fitz') 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; -- cgit v1.2.3