The size of the array necessary to store a complete screen image for each display depends on the resolution and on the number of colors the display supports. GESCAPE CRT,3 can be used in a program to determine the size necessary:
10 INTEGER S(5)
20 GESCAPE CRT,3;S(*)
30 PRINT "Array size is";S(4);"rows and";S(5);"columns."
40 END
The following table gives the sizes for some PC display adapters. The array may be declared larger or smaller than the size given. If the array is not large enough to contain a full screen image, GLOAD stops when all the array contents have been transferred. If the array is too large, only part of the array will be used. If an attempt is made to GLOAD an image to a display that is different from the GSTORE display, unpredictable results will occur. If the color map has different values than when the image was GSTOREd, the colors will not match the original image.
|
Display
|
Array Size
|
|
640x480x16
|
Image(1:160,1:480)
|
|
800x600x16
|
Image(1:200,1:600)
|
|
1024x768x16
|
Image(1:256,1:768)
|
|
640x480x256
|
Image(1:320,1:480)
|
|
800x600x256
|
Image(1:400,1:600)
|
|
1024x768x256
|
Image(1:512,1:768)
|
Below is an example of the GSTORE and GLOAD statements for a 1024 x 768 x 256 screen. Change line 10 to the appropriate size for your resolution.
10 INTEGER Image(1:512,1:768)
20 FRAME
30 DRAW 50,50
40 POLYGON 10,10,FILL
50 GSTORE Image(*)
60 END
Now that the image is stored in the array, clear the graphics screen with the GCLEAR statement. To load the image back onto the screen, use the following statement:
GLOAD Image(*)
Rectangular Blocks
GSTORE Image(*),Width,Height,Rule,Xorigin,Yorigin
When a Width and Height are specified after the image array, only a rectangular block is transferred between the array and the display. Width and Height are specified in pixels. Optionally, a Rule can be specified that instructs GLOAD/GSTORE how to combine the contents of the array with the contents of the screen. Presently, only a value of 3 is supported. This causes the contents of the array (for GLOAD) or screen (for GSTORE) to totally overwrite the target. The block will be located with the upper left corner at the current graphic position. Alternately, a position can be specified with the Xorigin, Yorigin parameters. These parameters should be specified in the current WINDOW units, not pixels or VIEWPORT units (GDUs).
For displays with 8 planes or less (256 colors or less), the image is stored with one byte per pixel. This makes images somewhat transportable among different displays. It also means that the number of elements necessary to store the image is equal to Width*Height/2. If the width is even, the array could be declared as
INTEGER Image( 1:Width/2,1:Height)
If the array is too small, an error is given. If the array is too large, the extra array elements are ignored. If GLOAD is used to display an image on a display with less colors than the GSTORE display, the results are undefined. If the color map is different than the color map in effect when the image was GSTOREd, the colors will not match the original image. The format of the data in the array for full screen images is stored as a bitmap.