Loading Pictures

Most programs will use a graphic image of some sort. It may be a splash screen, a background, buttons and window controls and so on. Here is a program that will load a graphic image and display it on the screen. It can easily be adapted to be used in your own programs.

The first noteable command is Defaultwin 2. This puts the Psion Series 5 into 16-gray display mode. (Defaultwin 1 is standard 4-grays and Defaultwin 0 is black and white.)

After this is the command to load the graphic file i%=gloadbit("c:\raceform.mbm",0,0). Where is it loaded? It doesn't matter. The Psion knows where it is and it makes i% a sort of pointer, which is all you need. The first 0 near the end of the command means make the graphic write-only - in other words, we can't change it in any way. If it was 1 we could change the image and resave it. (We might want to to this if we were writing a drawing program, then we could save our artwork.)

The last 0 in gloadbit means load the first image. An mbm graphic file can contain several images (a bit like the way an animated gif on the web contains several images in one file). The last 0 means load image 0 from the file. Change this to 1, 2, 3 and so on to load other images. However, you mustn't try to load an image that isn't there! If there are only two images in the file (which will be 0 and 1), don't try to load image 3.

Graphics are displayed in windows - all numbered - and the default window is 1. To specifiy this window we use gUse 1 - use graphic window 1. What we need to do is copy the graphic image from wherever the Psion loaded it to, to the current graphic window. We use
gCopy i%,0,0,640,240,0.

The i% tells the gCopy command to get the information from i%, which if you remember, points to our loaded image. The 0,0 is the place to put the image (the top left corner of the screen is 0,0), and the 640,240 means copy a block of the graphic 640 pixels wide by 240 pixels down, which is the same width and height of the screen. It doesn't seem to matter if the image is smaller than 640 x 240 pixels as the gCopy command only copies as much as it needs. If the image is only 50 x 100 then that's all that is copied.

The final 0 on the gCopy command is the mode. 0 means replace all pixels, overwriting what is currently on the screen. You can experiment with the other values 1 (clear), 2 (invert) and 3 (replace).

When we have finished with the graphic we remove it from memory with gClose i%.

PROC showpic:
Local i%
Defaultwin 2
i%=gloadbit("c:\raceform.mbm",0,0)
gUse 1
gCopy i%,0,0,640,240,0
gClose i%
Get
ENDP
 

Back to RAW Computing

  Psion home page