Commits

Anonymous committed bfba514

Fix pixel length in SDL_CreateRGBSurfaceFrom

  • Participants
  • Parent commits 9b39448
  • Branches ctypes-soc

Comments (0)

Files changed (1)

 
     :rtype: `SDL_Surface`
     '''
-    if len(pixels) == width * height:
+    if len(pixels) == pitch * 8 / depth * height:
         # pixel array?
         if depth == 8:
             ar = SDL.array.to_ctypes(pixels, len(pixels), c_ubyte)
             ar = SDL.array.to_ctypes(pixels, len(pixels), c_ushort)
         elif depth == 32:
             ar = SDL.array.to_ctypes(pixels, len(pixels), c_uint)
-    elif len(pixels) == width * height * depth / 8:
+    elif len(pixels) == pitch * height:
         # byte array
         ar = SDL.array.to_ctypes(pixels, len(pixels), c_ubyte)
     else: