Skip to content

LoadImage

Narta Xaymar Dirks edited this page Nov 1, 2026 · 10 revisions

Blitz3DBlitzPlusBlitzBasic

LoadImage

LoadImage:Int32 bmpfile:String
Parameter Mode Type Default Description
bmpfile In String required

Returns: A handle for the image, or 0 if the file could not be loaded.

Description

Loads a picture file into an image with one frame. Pixels that are black are drawn as transparent by DrawImage until MaskImage picks another color. Load images once at the start of a program and draw them often. If the file is missing, the result is 0, so check it before drawing.

Differences

  • A glTF file (.glb or .gltf) gives the pictures inside it: "model.glb" is the first and "model.glb#2" the third, see glTF models.
  • JPEG 2000 files do not load, and TIFF files with Deflate or JPEG compression do not, which the original read. WebP, AVIF, JPEG XL and some other formats load instead, see Image formats. Files are decoded by SDL_image, and DDS files (DXT1 to DXT5, BC4, BC5, BC7 and uncompressed pictures) by the runtime itself, and block compressed ones stay compressed on the graphics card until the image is drawn to. See LoadTexture for the formats of DDS files that are read.
  • Backslashes in paths are changed into slashes on Linux and macOS, and a name that is not found as written is looked for in any case, as on Windows.

Examples

Graphics 320, 240, 0, 2
SetBuffer BackBuffer()
; Make a picture file first so that the example runs without any other file.
Local made = CreateImage(64, 64)
SetBuffer ImageBuffer(made)
Color 80, 200, 120
Oval 0, 0, 64, 64, 1
SetBuffer BackBuffer()
SaveImage made, "dot.bmp"

Local img = LoadImage("dot.bmp")
If img = 0 Then RuntimeError "dot.bmp could not be loaded"
Cls
DrawImage img, 128, 88
Flip
WaitKey

Related Commands

CopyImage, CreateImage, DrawImage, FreeImage, GrabImage, HandleImage, LoadAnimImage, MaskImage

Home · Command Index



Differences
Language Features
BlitzBasic
Blitz3D
BlitzPlus

Clone this wiki locally