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,
+ _from_PIL(image, tmpsurf)
+ SDL_BlitSurface(tmpsurf, None, surf, None)
dest_pitch = image.size * surf.format.BytesPerPixel