The photograph’s resolution is 5616×3744, as you can see in the Image Viewer’s title bar. Its
resolution makes this still photo of an encased Raspberry Pi an ultra HD image.
The resolution of the pictures you want to present via your Raspberry Pi is up to you. Just remember
that higher resolution photos generally provide a clearer image.
Creating the Image Presentation Script
To create the HD image presentation script, you need to draw on the Python skills you’ve learned so
far. For this script, you will be using several methods from the PyGame library.
The following are the basics for importing and initializing the PyGame library:
Click here to view code image
import pygame #Import PyGame library
from pygame.locals import * #Load PyGame constants
pygame.init() #Initialize PyGame
This should look very familiar because the PyGame library is covered in Hour 19, “Game
Programming.” If you need a refresher on using PyGame, go back and review that hour.
Setting Up the Presentation Screen
At this point, you need to determine what color you want to make the background screen. Your photos
or images should guide your choice of the best background color to use. In general, you should use a
monochrome color such as black, white, or gray. To generate the necessary background color, you
need to set the RGB color settings. The RGB setting to achieve white is 255,255,255. Black is
0,0,0. The following example uses gray, with a setting of 125,125,125:
Click here to view code image
ScreenColor = Gray = 125,125,125
Notice that two variables are set up: ScreenColor and Gray. Using two variables not only makes
the script more readable but gives you some flexibility in your script. If you plan to always use gray
as your background color, you can use the Gray variable throughout the script. If you want to change
the background color, you can use the variable ScreenColor in your script.
Flexibility is the name of the game with this Python script. The script you’re creating now is very
flexible. It will allow you to walk into a room and use whatever size presentation screen is available.
It could be a 30-inch computer monitor sitting on your client’s desk, a 75-inch television screen at
your neighbor’s house, or a 10-inch tablet at school. You will not need to edit your script to use the
full screen size when you arrive at your presentation site, no matter what the screen size is! To
accomplish this feat, when the screen is initialized using pygame.display.set_mode, you use
the flag FULLSCREEN, as shown here:
Click here to view code image
ScreenFlag = FULLSCREEN | NOFRAME
PrezScreen = pygame.display.set_mode((0,0),ScreenFlag)
This causes the PyGame display screen to be set to the full size of the screen the script is
encountering at that moment.
Notice that in addition to using FULLSCREEN, you also use the NOFRAME flag. This causes any
frames around your screen to disappear during your presentation, allowing the entire available screen