How can I tell if a surface has per-pixel alpha?
I wrote this function to scale an arbitrary surface, but it fails if
the surface has per-pixel alpha (the background shows up
TRANSPARENT instead of transparent) with this output:
Hm... I changed my TRANSPARENT color to have an alpha channel
and now it works the way I want... That's good. I am still a bit fuzzy
on the distinctions between colorkey, alpha, and per-pixel alpha
though, if someone feels like explaining something :o)
import pygame
TRANSPARENT = (0, 51, 0, 0)
def scale_image(img, width, height, keepAspectRatio=1):
"""return a scaled copy of a L{pygame.Surface}
@param img: Original L{pygame.Surface}.
@param width: width of returned surface.
@param height: height of returned surface.
@param keepAspectRatio: If True, the returned surface will be padded
with
transparent borders.