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 _LOADIMAGE function loads an image into memory and returns valid LONG image handle values that are less than -1.

Syntax

handle& = _LOADIMAGE(filename$[, mode%])

Parameter(s)

Description

Error(s)

Example(s)

To display an image in 32-bit color using its resolution as a program screen:


i& = _LOADIMAGE("mypic.jpg", 32)
SCREEN i& 

DRAWing and rotating an image 360 degrees using Turn Angle. POINT is used to read the invisible image source.


SCREEN _NEWIMAGE(800, 600, 32)
img& = _LOADIMAGE("QB64.PNG")                           'load the image file to be drawn

wide% = _WIDTH(img&): deep% = _HEIGHT(img&)
TLC$ = "BL" + STR$(wide% \ 2) + "BU" + STR$(deep% \ 2)  'start draw at top left corner
RET$ = "BD BL" + STR$(wide%)                            'return to left side of image
_SOURCE img&
_DEST 0
DO
  FOR angle% = 0 TO 360 STEP 15
    CLS
    DRAW "BM400, 300" + "TA=" + VARPTR$(angle%) + TLC$
    FOR y = 0 TO deep% - 1
      FOR x = 0 TO wide% - 1
        DRAW "C" + STR$(POINT(x, y)) + "R1"            'color and DRAW each pixel
      NEXT
      DRAW RET$
    NEXT
    _DISPLAY                         'NOTE: CPU usage will be HIGH!
  NEXT
LOOP UNTIL INKEY$ > "" 

NOTE: Speed varies with image size.

More examples

See Also