Learn Before
Code

Loading an Image onto a Surface in Pygame

There are three functions for loading images: load_basic(), load(), and load_extended(). Load_basic() only supports uncompressed BMP file formats. If Pygame was built with extended image support, load() should be able to process most image formats--if not, it will be the same as load_basic(). Load_extended() is similar to load() but can only be called if Pygame was built with extended image support. Each of these functions takes in a filename or file-like object and returns a Surface containing the image.

basicImage = 'cat.bmp' image = 'cat.png' surfaceA = pygame.image.load_basic(basiscImage) surfaceB = pygame.image.load(image) surfaceC = pygame.image.load_extended(image)

0

1

Updated 2021-06-21

Tags

Python Programming Language

Data Science