Fix composite on big-endian systems.
authorAndrea Canciani <ranma42@gmail.com>
Sun, 27 Sep 2009 09:40:52 +0000 (11:40 +0200)
committerSøren Sandmann Pedersen <sandmann@redhat.com>
Sun, 27 Sep 2009 13:35:02 +0000 (09:35 -0400)
Data narrower than 32bpp is padded to an unsigned long and on
big-endian systems this shifts the value by the padding bits.

test/composite.c

index bcd26ff..7996251 100644 (file)
@@ -25,6 +25,7 @@
 #include <stdio.h>
 #include <stdlib.h> /* abort() */
 #include <math.h>
+#include <config.h>
 
 #define FALSE 0
 #define TRUE !FALSE
@@ -502,6 +503,9 @@ get_pixel (pixman_image_t *image,
     unsigned long val;
 
     val = *(unsigned long *) pixman_image_get_data (image);
+#ifdef WORDS_BIGENDIAN
+    val >>= 8 * sizeof(val) - PIXMAN_FORMAT_BPP (format);
+#endif
 
     /* Number of bits in each channel */
     a = PIXMAN_FORMAT_A (format);