QBasic 1.1: GET (Graphics) Statement

Syntax

GET [STEP](x1!,y1!)-[STEP](x2!,y2!), arrayname[(index%)]
PUT [STEP] (x1!,y1!), arrayname[(index%)] [,actionverb]

Description / Parameter(s)

STEP Specifies that coordinates are relative to the current graphics cursor position.
(x1!,y1!) The upper-left coordinates of the image captured by GET or of the screen location where PUT displays the image.
(x2!,y2!) The lower-right coordinates of the captured image.
arrayname The name of the array where the image is stored. See Screen Image Arrays and Compatibility below to determine the required size of the array.
index% The array index at which storage of the image begins.
actionverb A keyword indicating how the image is displayed:
 
Keyword Action
AND Merges stored image with an existing image.
OR Superimposes stored image on existing image.
PSET Draws stored image, erasing existing image.
PRESET Draws stored image in reverse colors, erasing existing image.
XOR Draws a stored image or erases a previously drawn image while preserving the background, producing animation effects.
A PUT statement should always be executed in the same screen mode as the GET statement used to capture the image, or a compatible mode. See Screen Image Arrays and Compatibility below.

Screen Image Arrays and Compatibility
Use bits-per-pixel-per-plane and planes values to determine the required size of the array that holds a graphics screen image. Bits-per-pixel-per-plane and planes values, along with the horizontal resolution, also determine which screen modes are compatibile:
Screen mode Bits-per-pixel-per-plane Planes Horizontal resolution (in pixels)
1 2 1 320
2, 4, 11 1 1 640
3 1 1 720
7 1 1 320
8, 9(> 64K video memory), 12 1 4 640
9(64K video memory), 10 1 2 640
13 8 1 320
The following formula gives the required size, in bytes, of an array used to hold a captured image:
size% = 4 + INT(((PMAP (x2!, 0) - PMAP (x1!, 0) + 1) *
        (bits-per-pixel-per-plane%) + 7) / 8) * planes% *
        (PMAP (y2!, 1) - PMAP (y1!, 1) + 1)
GET and PUT operations are compatible in screen modes with the same horizontal resolution and bits-per-pixel-per-plane and planes values. For example, screen modes 2, 4, and 11 are compatible, and screen modes 8 and 12 are compatible.

Example

'This example requires a color graphics adapter. SCREEN 1 DIM Box%(1 TO 200) x1% = 0: x2% = 10: y1% = 0: y2% = 10 LINE (x1%, y1%)-(x2%, y2%), 2, BF GET (x1%, y1%)-(x2%, y2%), Box% DO PUT (x1%, y1%), Box%, XOR x1% = RND * 300 y1% = RND * 180 PUT (x1%, y1%), Box% LOOP WHILE INKEY$ = ""