Commits

Anonymous committed 97c874f

Software blitting BGR surface

  • Participants
  • Parent commits 5a307ba
  • Branches ctypes-soc

Comments (0)

Files changed (3)

 Pygame-ctypes 0.10
 ------------------
  - Fixed unset colorkey with Surface.set_colorkey
+ - Performance of simple (non error-checking) SDL/pygame functions improved
+ - Software blitting BGR surfaces corrected.
 
 Pygame-ctypes 0.09
 ------------------
 pygame:
 mac default icon
 search libs e.g. SDL_ttf-2.0 before SDL_ttf
+24-bit don't assume RGB, could be BGR.

pygame/surface.py

 
         if src24:
             src2d_rect = src2d[srcy:srcy+h,srcx:srcx+w*3]
-            sR = src2d_rect[:,::3]
-            sG = src2d_rect[:,1::3]
-            sB = src2d_rect[:,2::3]
+            sR = src2d_rect[:,srcRshift >> 3::3]
+            sG = src2d_rect[:,srcGshift >> 3::3]
+            sB = src2d_rect[:,srcBshift >> 3::3]
             sA = 255
         else:
             src2d_rect = src2d[srcy:srcy+h,srcx:srcx+w]
             # XXX TODO This is completely untested.  The planes probably
             # need to be cast to a larger data type.
             dst2d_rect = dst2d[dstrect.y:dstrect.y+h,dstrect.x:dstrect.x+w*3]
-            dR = dst2d_rect[:,::3]
-            dG = dst2d_rect[:,1::3]
-            dB = dst2d_rect[:,2::3]
+            dR = dst2d_rect[:,dstRshift >> 3::3]
+            dG = dst2d_rect[:,dstGshift >> 3::3]
+            dB = dst2d_rect[:,dstBshift >> 3::3]
             dA = 255
         else:
             dst2d_rect = dst2d[dstrect.y:dstrect.y+h,dstrect.x:dstrect.x+w]
 
         # Finished, set result.
         if dst24:
-            dst2d_rect[:,::3] = dR
-            dst2d_rect[:,1::3] = dG
-            dst2d_rect[:,2::3] = dB
+            dst2d_rect[:,dstRshift >> 3::3] = dR
+            dst2d_rect[:,dstGshift >> 3::3] = dG
+            dst2d_rect[:,dstBshift >> 3::3] = dB
         else:
             dst2d_rect[:,:] = ((dR >> dstRloss) << dstRshift) | \
                               ((dG >> dstGloss) << dstGshift) | \