2013-10-13 63 views
1

我不能在pygame中加載非BMP文件的圖像。我到處尋找解決方案,但找不到一個解決方案。 在pygame的網站,他們這樣說:完整的內置文件支持PYGAME

The image module is a required dependency of Pygame, but it only optionally supports any extended file formats. By default it can only load uncompressed BMP images. When built with full image support, the pygame.image.load - load new image from a file function can support the following formats.

我不明白做什麼,我怎麼能得到完整的構建映像支持。

我在ubuntu 13.04上運行python 3.3。 我是python的新手。

有幫助嗎?

錯誤:

File "/home2/tor/workspace/PYGAME/src/Main.py", line 13, in <module> 
ball = pygame.image.load("/home2/tor/Downloads/ball.gif") 
pygame.error: File is not a Windows BMP file 

順便說一句我也試過這樣的JPG文件。

+0

您是如何安裝pygame的? –

回答

0

您的Pygame版本可能對您的系統中的Python 3不夠用,我相信ubuntu 13.04自帶默認安裝的Python 3,我不確定它是否具有Python 2,但如果它碰巧擁有它,我會用它來代替。從這個問題

信息:PyGame.error in ubuntu

正下方的地方說:「能夠支持以下格式」列表中說:

JPG 
PNG 
GIF (non animated) 
BMP 
PCX 
TGA (uncompressed) 
TIF 
LBM (and PBM) 
PBM (and PGM, PPM) 
XPM 

雖然它說,它不是Windows BMP文件時,並不意味着它必須是bmp。我不認爲gif在列表中說明時支持動畫。

下面是一個png圖片的pygame評論的例子。

char_surf=pygame.image.load(os.path.join('data', 'char.png'))

+0

GIF不是動畫。 – Toalp