Python Programming for Raspberry Pi, Sams Teach Yourself in 24 Hours

(singke) #1

as shown here:


Click here to view code image


PrezScreenSize = PrezScreen.get_size()
Scale=PrezScreenSize

Within your picture display for loop, you add the following if statement to check the size of the
current picture. If the picture is larger than the current presentation screen, you have the script scale it
down to screen size by using pygame.transform.scale, like this:


Click here to view code image


# If Picture is bigger than screen, scale it down.
if Picture.get_size() > PrezScreenSize:
Picture = pygame.transform.scale(Picture,Scale)

This causes that one oversized photo in Figure 23.4 to now look like a great HD picture, as shown in
Figure 23.5.


FIGURE 23.5 A photo sized correctly for the display screen.

Now that the photo is correctly sized, you can see the entire Raspberry Pi and not just a single chip.
Also, the paper clip is now showing, giving the viewing audience a nice size comparison.


Framing the Photos


To make your photo presentation just a little nicer, you can add a frame to all your photos. Just a
minor adjustment to your Scale variable, as shown here, does the trick:


Click here to view code image


Scale=PrezScreenSize[0]-20,PrezScreenSize[1]-20

Now that you’ve added the frame, your photos will look as shown in Figure 23.6. Each one will have

Free download pdf