我想使用pygame手动创建 colored颜色 索引图像(调色板)并将其保存为PNG文件:
# create the bitmap
res = pygame.Surface((src.width, src.height), depth=8)
# create the palette
res.set_palette([pygame.Color((0, 0, 0, 0)), ...])
pygame.image.save(res, "test.png")
但我得到:
error: cannot set palette without pygame.display initialized
在set_palette
线上.
当然,初始化一些虚拟显示并不困难,但我不明白为什么会这样.没有显示任何内容,在我的代码中似乎没有任何内容依赖于显示...
此外,在操作32位曲面时初始化pygame或display是完全无用的.他们之间有什么区别?