QB64.com

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 _COPYIMAGE function creates an identical designated image in memory with a different negative LONG handle value.

Syntax

newhandle& = _COPYIMAGE[(imageHandle&[, mode%)]]

Parameter(s)

Description

Use CLS or _DONTBLEND to make a new surface background _ALPHA 255 or opaque.

Example(s)

Restoring a Legacy SCREEN using the _COPYIMAGE return value.


SCREEN 13
CIRCLE (160, 100), 100, 40
DO: SLEEP: LOOP UNTIL INKEY$ <> ""

'backup screen before changing SCREEN mode
oldmode& = _COPYIMAGE(0)  'the 0 value designates the current destination SCREEN

s& = _NEWIMAGE(800, 600, 32)
SCREEN s&
LINE (100, 100)-(500, 500), _RGB(0, 255, 255), BF
DO: SLEEP: LOOP UNTIL INKEY$ <> ""

SCREEN oldmode&        'restore original screen
IF s& < -1 THEN _FREEIMAGE s&
END

Note: Only free valid handle values with _FREEIMAGE AFTER a new SCREEN mode is being used by the program.

Program that copies desktop to a hardware image to form a 3D triangle:


SCREEN _NEWIMAGE(640, 480, 32)
my_hardware_handle = _COPYIMAGE(_SCREENIMAGE, 33) 'take a screenshot and use it as our texture
_MAPTRIANGLE (0, 0)-(500, 0)-(250, 500), my_hardware_handle TO_ 
(-1, 0, -1)-(1, 0, -1)-(0, 5, -10), , _SMOOTH
_DISPLAY
DO: _LIMIT 30: LOOP UNTIL INKEY$ <> ""

See Also