Learn Before
Concept

Images in Pygame

The image module contains functions for loading and saving image files. Images will be loaded as Surface objects. Images can be saved by passing in the Surface you want to make an Image file out of. The module will then generate an image file from the Surface. Note that there are no image objects in Pygame--images are stored on Surfaces. The Surface class will allow you to manipulate the image on the Surface by selecting and modifying regions of it, along with drawing over it with lines and other shapes (see Drawing in Pygame). By default only uncompressed BMP images can be loaded. When built with full image support, the pygame.image.load() function can support the following formats:

  • JPG
  • PNG
  • GIF (non-animated)
  • BMP
  • PCX
  • TGA (uncompressed)
  • TIF
  • LBM (and PBM)
  • PBM (and PGM, PPM)
  • XPM

Saving images only supports a limited set of formats. You can save to the following formats:

  • BMP
  • TGA
  • PNG
  • JPEG

0

1

Updated 2021-06-21

Tags

Python Programming Language

Data Science

Related