How to load PNG files with pygame.image?

前端 未结 1 1250
名媛妹妹
名媛妹妹 2020-12-21 10:57

I\'m simply trying to load an image with pygame with that piece of code :

import pygame
myimage = pygame.image.load(\"bla.png\")

And I get

相关标签:
1条回答
  • 2020-12-21 11:52

    The Pygame documentation for images explicitly says

    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.

    So, I suppose you should run

    pygame.image.get_extended() # returns a bool
    

    to check if you can load images of other extensions. If not, I suppose you will need Python imaging libraries to be installed to get extended file formats to be supported by Pygame.

    OR, you could always convert the images to BMP to avoid the hassle.

    0 讨论(0)
提交回复
热议问题