2016-05-21 39 views
0

我试图从不在起始目录中的文件加载图像。
到目前为止,我有:从不同目录加载png图像Python Pygame

BG_f = open("pictures/adventure background.png","r") 

后来我想这个图像BitBlt到屏幕上,但我得到:

screen.blit(BG_f,(0,0)) 
TypeError: argument 1 must be pygame.Surface, not file 

于是我尝试:

BG = pygame.image.load(BG_f) 

但只返回:

libpng error: PNG file corrupted by ASCII conversion 
... 
pygame.error: Error reading the PNG file. 

显然我做错了什么。我试图查看如何,但我只能找到如何加载图像在起始目录。我只需要最基本的语法;我不太流利的python,sys或os(如果这些是必要的)。

回答

0

DUH我在做这一切错,只是尝试:

BG = pygame.image.load("pictures/adventure background.png") 

和它的工作! NVM