def __init__(self, srf, bg=None, decompress=zlib.decompress):
if hasattr(srf, "image"): srf = srf.image
t = type(srf)
if t is str:
srf = pygame.image.load(srf)
if bg: srf = style(srf, bg)
elif not hasAlpha(srf): srf = srf.convert_alpha()
elif t is bytes:
mode, w, h = struct.unpack("!3I", bg)
if mode & 2: srf = decompress(srf)
mode = "RGBA" if mode & 1 else "RGB"
srf = pygame.image.fromstring(srf, (w,h), mode)
elif t in (list, tuple):
srf = pygame.Surface(srf, pygame.SRCALPHA)
if bg: srf.fill(bg if type(bg) is pygame.Color else rgba(bg))
self.original = srf
self.dumpCache()
评论列表
文章目录