util.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:sc8pr 作者: dmaccarthy 项目源码 文件源码
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()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号