尝试在python中加载位图图像
我正在用python加载一个我认为合适的图像,但它仍然没有显示出来。我不知道图像是太大还是什么尝试在python中加载位图图像,python,pygame,Python,Pygame,我正在用python加载一个我认为合适的图像,但它仍然没有显示出来。我不知道图像是太大还是什么 import pygame import math pygame.display.init() window = pygame.display.set_mode((600, 500)) mapImg = pygame.image.load("mapoftheusa.bmp") done = False while not done: window.fill((0,0,0)) e
import pygame
import math
pygame.display.init()
window = pygame.display.set_mode((600, 500))
mapImg = pygame.image.load("mapoftheusa.bmp")
done = False
while not done:
window.fill((0,0,0))
evtList = pygame.event.get()
for evt in evtList:
if evt.type == pygame.QUIT:
done = True
window.blit(mapImg, (0,0)) #<<will not blit
pygame.quit()
导入pygame
输入数学
pygame.display.init()
window=pygame.display.set_模式((600500))
mapImg=pygame.image.load(“mapousa.bmp”)
完成=错误
虽然没有这样做:
窗口填充((0,0,0))
evtList=pygame.event.get()
对于evt列表中的evt:
如果evt.type==pygame.QUIT:
完成=正确
window.blit(mapImg,(0,0))#您忘记在window.blit(mapImg,(0,0))
之后添加对pygame.display.update()
的调用
因此,您的完整代码应该是:
import pygame
import math
pygame.display.init()
window = pygame.display.set_mode((600, 500))
mapImg = pygame.image.load("mapoftheusa.bmp")
done = False
while not done:
window.fill((0,0,0))
evtList = pygame.event.get()
for evt in evtList:
if evt.type == pygame.QUIT:
done = True
window.blit(mapImg, (0,0)) #<<will not blit
pygame.display.update() # solution: you forgot this...
pygame.quit()
导入pygame
输入数学
pygame.display.init()
window=pygame.display.set_模式((600500))
mapImg=pygame.image.load(“mapousa.bmp”)
完成=错误
虽然没有这样做:
窗口填充((0,0,0))
evtList=pygame.event.get()
对于evt列表中的evt:
如果evt.type==pygame.QUIT:
完成=正确
blit(mapImg,(0,0))35;那么您不会得到任何错误输出或任何东西-程序运行,但图像不显示?