0

我的 pygame 代码

bif="images.jpg"
mif="point.png"
import pygame, sys
from pygame.locals import *

pygame.init()
screen=pygame.display.set_mode((640,360),0,32)
background=pygame.image.load(bif).convert()
mouse_c=pygame.image.load(mif).convert_alpha()
while True:
        for event in pygame.event.get():
                if event.type == QUIT:
                        pygame.quit()
                        sys.exit()
        screen.blit(background, (0,0))

错误信息

Traceback (most recent call last):
  File "game.py", line 8, in <module>
    background=pygame.image.load(bif).convert()
pygame.error: File is not a Windows BMP file

相同的代码适用于不同的机器,但不适用于我的机器。

谁能帮我解决这个问题

如何从我的 ubuntu 机器上卸载整个 python 然后重新安装。

4

1 回答 1

1

Pygame 通常会加载 png 文件。其他几种文件类型将不起作用。并不总是支持 Jpeg。如果您想绝对确定图像将正确加载,请使用未压缩的位图格式,但 png 应该可以工作。您可以通过多种方式将 jpg 文件转换为 png 格式,例如使用图像编辑器将其保存为不同的格式,或者只是在线下载格式转换软件。如果仅加载 png 文件,则不会出现错误。

于 2013-11-25T02:08:29.680 回答