Commits

Anonymous committed 20d154c

Fixed mask settings for 8-bit surfaces created by surfarray.make_surface()

  • Participants
  • Parent commits 0b2c285

Comments (0)

Files changed (2)

File lib/_numpysurfarray.py

     if len (shape) == 2:
         # 2D array
         bpp = 8
-        
+        r = 0xFF >> 6 << 5
+        g = 0xFF >> 5 << 2
+        b = 0xFF >> 6
     elif len (shape) == 3 and shape[2] == 3:
         bpp = 32
         r = 0xff << 16
 
     itemsize = array.itemsize
     data = array.tostring ()
-    
+
     if itemsize > bpp:
         # Trim bytes from each element, keep least significant byte(s)
         pattern = '%s(%s)' % ('.' * (itemsize - bpp), '.' * bpp)

File src/_numericsurfarray.c

     if (array->nd == 2)
     {
         bitsperpixel = 8;
-        rmask = gmask = bmask = 0;
+        rmask = 0xFF >> 6 << 5;
+        gmask = 0xFF >> 5 << 2;
+        bmask = 0xFF >> 6;
     }
     else
     {