util.py 文件源码

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

项目:sc8pr 作者: dmaccarthy 项目源码 文件源码
def surfaceData(srf, compress=zlib.compress):
    "Convert surface to bytes data with optional compression"
    if not isinstance(srf, pygame.Surface): srf = srf.image
    w, h = srf.get_size()
    a = hasAlpha(srf)
    mode = (1 if a else 0) + (2 if compress else 0)
    mode = struct.pack("!3I", mode, w, h)
    data = pygame.image.tostring(srf, "RGBA" if a else "RGB")
    return (compress(data) if compress else data), mode
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号