Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/285.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
尝试在python中加载位图图像_Python_Pygame - Fatal编程技术网

尝试在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

我正在用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))
    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;那么您不会得到任何错误输出或任何东西-程序运行,但图像不显示?