QB64 is a modern extended BASIC programming language that retains QBasic/QuickBASIC 4.5 compatibility and compiles native binaries for Windows, Linux, and macOS.

The PUT graphics statement is used to place GET (graphics statement) or BSAVE file images stored in the designated array.


PUT [STEP](column, row), Array([index])[,] [_CLIP] [{PSET PRESET AND OR XOR}]][, omitcolor]




How GET and PUT can be used with images loaded with _LOADIMAGE. The background color is omitted or “masked”.

SCREEN _NEWIMAGE(640, 480, 256)
image& = _LOADIMAGE("QB64.png")  'replace with your own image

wide& = _WIDTH(image&): deep& = _HEIGHT(image&)
DIM Array(wide& * deep&) AS INTEGER

_SOURCE image&              'REQUIRED to GET the proper image area!
GET (0, 0)-(wide& - 1, deep& - 1), Array(0)

_COPYPALETTE image&, 0      'necessary for custom image colors other than screen defaults
PUT(10, 10), Array(0), PSET , _RGB(255, 255, 255)   'mask white background color

Explanation: QB64 allows one PUT color to be “masked” to allow odd shaped sprite image backgrounds to be transparent.

Using a STRING instead of an arrays to store GET image data that can be PUT later. For images up to 256 colors only.

a$ = SPACE$(4 + 100)            '4 byte header + 100 pixels for a 10 X 10 image
LINE (0, 0)-(319, 199), 4, BF   'color 4 = CHR$(4) = ♦
LINE (40, 40)-(49, 49), 14, B   'color 14 = CHR$(14) = ♫
GET (40, 40)-(49, 49), a$

K$ = INPUT$(1)

PRINT a$                        'display string data. Width = CHR$(10 * 8) = "P"
PUT(100, 100), a$, PSET 

Explanation: The header holds the INTEGER width and depth of the image area as 2 bytes each. Screen 13 width is multiplied by 8.

See Also