2024-04-20 13:23:07 发布
网友
我在pygame程序中有一个图像代码:
img_string = pygame.image.tostring(img, "RGB")
然后我将这个字符串保存到一个文件中,并希望能够使用image.tobuffer函数再次打开它。但是,我需要将它转换回24bi字节。我试过img_bytes = bytes(img, 'utf-8'),当然不行,我也找不到正确的格式。你知道吗
image.tobuffer
img_bytes = bytes(img, 'utf-8')
如果你能帮助我,非常感谢!你知道吗
合理地说,根据the documentation,当您用tostring()创建它时,您应该用fromstring()而不是frombuffer()将它转换回来。你知道吗
tostring()
fromstring()
frombuffer()
合理地说,根据the documentation,当您用
tostring()
创建它时,您应该用fromstring()
而不是frombuffer()
将它转换回来。你知道吗相关问题 更多 >
编程相关推荐