TUTORIAL SIX
PHOTO COPIER

The purpose of this program is to demonstrate how to load a bitmap onto the screen and manipulate the image. The program loads the picture then grabs four equal segments from it, storing the images in memory. The images are then pasted back onto the screen clockwise. By repeating this action, the segments will appear to be rotating around the screen in a clockwise direction.

This tutorial program can be loaded directly into the editor by clicking SAMPLE06.DBA.

rem Load a bitmap onto the screen
LOAD BITMAP "sample.bmp"

rem Begin loop
DO

rem Grab all four quarters of the screen
GET IMAGE 1,0,0,320,240
GET IMAGE 2,320,0,640,240
GET IMAGE 3,320,240,640,480
GET IMAGE 4,0,240,320,480

rem Paste in their neighbors quarter
PASTE IMAGE 1,320,0
PASTE IMAGE 2,320,240
PASTE IMAGE 3,0,240
PASTE IMAGE 4,0,0

rem Small delay
SLEEP 100

rem End loop
LOOP

The LOAD BITMAP command takes the filename of a media file in the BMP file format. The media file has to be in the same directory as the program. When the GET IMAGE command is used, it copies the specified area from the screen and stores it in memory. This image can then be pasted to any location. The SLEEP command works in units of 1000 per second, and is used to momentarily pause the program.

Final Step : Things for you to do

1. Change the program to slow down the rate of clockwise rotation
2. Change the program to make the segments rotate anti-clockwise
3. Change the program to divide the picture up into smaller tiles when rotating

You can skip to the next tutorial by selecting TUTORIAL SEVEN.