小编use*_*111的帖子

将PIL图像转换为pygame表面图像

我正在尝试使用PIL.Image将.png图像加载到程序中,以便可以操纵它们,以用作sprite中的pygame表面。以下代码显示了我如何尝试将这些Pil图片转换为pygame图片:

bytes = someImagefile.tobytes()
new_image = pygame.image.fromstring(bytes, size, "RGB")
Run Code Online (Sandbox Code Playgroud)

我得到:“ ValueError:字符串长度不等于格式和分辨率大小”

在我玩完之后,有没有没有保存新的.png副本的方法?

python pygame image python-imaging-library

2
推荐指数
1
解决办法
2439
查看次数

标签 统计

image ×1

pygame ×1

python ×1

python-imaging-library ×1