Commits

Anonymous committed 469b378

16-bit transform.scale

Comments (0)

Files changed (3)

  - pygame.Surface.set_at and .get_at for 24-bit surfaces.  Largely untested.
  - pygame.transform.rotozoom 24-bit surfaces.
  - pygame.draw.polygon accepts tuple as well as list
+ - pygame.Surface.fill fix for zero-width or zero-height rectangle
+ - pygame.transform.scale for 16-bit surfaces.
 
 SDL-ctypes 0.10
 ---------------
         if type(color) not in (int, long):
             raise 'invalid color argument'
 
-        if rect:
+        if rect is not None:
             rect = copy(pygame.rect._rect_from_object(rect))
         else:
             rect = pygame.rect.Rect(0, 0, surf.w, surf.h)
     return img
 
 def _from_PIL(image, surf):
+    if surf.format.BitsPerPixel == 16:
+        # Yikes.  We had to convert from 16-bit to 32-bit RGBA to go into PIL,
+        # now go back again to 16-bit.
+        assert image.mode == 'RGBA'
+        tmpsurf = SDL_CreateRGBSurface(SDL_SWSURFACE, 
+                                       surf.w, surf.h, 32,
+                                       SDL_SwapLE32(0x000000ff),
+                                       SDL_SwapLE32(0x0000ff00),
+                                       SDL_SwapLE32(0x00ff0000),
+                                       SDL_SwapLE32(0xff000000))
+        _from_PIL(image, tmpsurf)
+        SDL_BlitSurface(tmpsurf, None, surf, None)
+        SDL_FreeSurface(tmpsurf)
+        return
+        
     data = image.tostring()
 
     dest_pitch = image.size[0] * surf.format.BytesPerPixel