Raster Images
The last of the graphics elements we are going to examine in this chapter are raster images. These are the regular types of images used with computers such as those produced by displaying PNG or JPG files. They are presented as a grid of pixels where each pixel can be seen when the image is zoomed in, as illustrated in Figure 2.11:
Figure 2.11: A raster image of Smudge and a closeup of the corner of his eye showing individual pixels
If an image has a high resolution, you won’t be able to make out each pixel.
As mentioned in our discussion of creating text, in Pygame, images can be drawn onto surfaces that don’t appear on the main display until required. This also goes for raster images.
First, they are loaded into memory and then you can put them onto the display over and over again at different locations using screen.blit
. The image you choose can include transparency. This is a nice feature as it allows you to draw a sprite...