pygame.error:无法为PNG文件或不兼容的PNG dll分配内存

时间:2016-11-11 02:42:12

标签: python pygame png

我试图为我的Python类创建一个非常简单的空间入侵者pygame。我还没有到目前为止,但是当我尝试测试代码时,我一直收到图像加载错误。我正在使用Python 2.7和Pycharm。 这是我的源代码。

import pygame
from pygame.locals import *


pygame.init()
width, height = 640, 480
screen = pygame.display.set_mode((width, height))

player = pygame.image.load("spacecraft.png")

#infinite loop
while 1:
    screen.fill(0)
    screen.blit(player, (100,100))
    pygame.display.flip()
    #loop though the events
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            #if it is quit the game
            pygame.quit()
            exit()

同样,这只应显示黑色屏幕,其中包含这些坐标中的宇宙飞船的图片。但是,当我测试它时程序显示此错误:

libpng warning: Application built with libpng-1.6.23 but running with 1.5.4
line 9, in <module>
player = pygame.image.load("spacecraft.png")
pygame.error: Couldn't allocate memory for PNG file or incompatible PNG dll

我尝试重新安装Pygame,Python,并尝试使用os来正确地路径化图像。图像的路径是root,所以我检查了我的清单。 我也下载了libpng.1.6.16,但那也没有用。 我有办法解决这个问题吗?顺便说一句,我不熟悉内存管理。 如果您需要更多信息,我会尽力回答。

提前致谢!!

0 个答案:

没有答案
相关问题