Commits

Lenard Lindstrom committed 9ccc616

Big-endian fixes to pygame.PixelArray

The pixelarray_test.py unit tests now pass on a PowerPC

  • Participants
  • Parent commits b51cd33

Comments (0)

Files changed (2)

         Uint32 vGoffset = val_surf->format->Gshift >> 3;
         Uint32 vBoffset = val_surf->format->Bshift >> 3;
 #else
-        Uint32 Roffset = 2 - surf->format->Rshift >> 3;
-        Uint32 Goffset = 2 - surf->format->Gshift >> 3;
-        Uint32 Boffset = 2 - surf->format->Bshift >> 3;
-        Uint32 vRoffset = 2 - val_surf->format->Rshift >> 3;
-        Uint32 vGoffset = 2 - val_surf->format->Gshift >> 3;
-        Uint32 vBoffset = 2 - val_surf->format->Bshift >> 3;
+        Uint32 Roffset = 2 - (surf->format->Rshift >> 3);
+        Uint32 Goffset = 2 - (surf->format->Gshift >> 3);
+        Uint32 Boffset = 2 - (surf->format->Bshift >> 3);
+        Uint32 vRoffset = 2 - (val_surf->format->Rshift >> 3);
+        Uint32 vGoffset = 2 - (val_surf->format->Gshift >> 3);
+        Uint32 vBoffset = 2 - (val_surf->format->Bshift >> 3);
 #endif
         for (y = 0; y < dim1; ++y) {
             pixel_p = pixelrow;
         Uint32 Goffset = surf->format->Gshift >> 3;
         Uint32 Boffset = surf->format->Bshift >> 3;
 #else
-        Uint32 Roffset = 2 - surf->format->Rshift >> 3;
-        Uint32 Goffset = 2 - surf->format->Gshift >> 3;
-        Uint32 Boffset = 2 - surf->format->Bshift >> 3;
+        Uint32 Roffset = 2 - (surf->format->Rshift >> 3);
+        Uint32 Goffset = 2 - (surf->format->Gshift >> 3);
+        Uint32 Boffset = 2 - (surf->format->Bshift >> 3);
 #endif
         for (y = 0; y < dim1; ++y) {
             pixel_p = pixelrow;
         Uint32 Goffset = surf->format->Gshift >> 3;
         Uint32 Boffset = surf->format->Bshift >> 3;
 #else
-        Uint32 Roffset = 2 - surf->format->Rshift >> 3;
-        Uint32 Goffset = 2 - surf->format->Gshift >> 3;
-        Uint32 Boffset = 2 - surf->format->Bshift >> 3;
+        Uint32 Roffset = 2 - (surf->format->Rshift >> 3);
+        Uint32 Goffset = 2 - (surf->format->Gshift >> 3);
+        Uint32 Boffset = 2 - (surf->format->Bshift >> 3);
 #endif
         Uint8 r = (Uint8)(color >> 16);
         Uint8 g = (Uint8)(color >> 8);

src/pixelarray_methods.c

         break;
     case 3:
 #if SDL_BYTEORDER == SDL_LIL_ENDIAN
-        pixel = (pixel_p[0]) + (pixel_p[1] << 8) + (pixel_p[2] << 16);
+        pixel = ((Uint32)pixel_p[0] +
+      	         ((Uint32)pixel_p[1] << 8) +
+                 ((Uint32)pixel_p[2] << 16));
 #else
-        pixel = (pixel_p[2]) + (pixel_p[1] << 8) + (pixel_p[0] << 16);
+        pixel = ((Uint32)pixel_p[2] +
+                 ((Uint32)pixel_p[1] << 8) +
+                 ((Uint32)pixel_p[0] << 16));
 #endif
         break;
     case 4: