Skip to content

lcd.loadBitmap

since 1.1.0

Load a bitmap from a file. Allowed formats are BMP / JPG / PNG. Transparency is supported, but it will use more resources.

local bitmapHandle = lcd.loadBitmap(path[, lazy])

Parameters

Name Type Required Description
path string yes bitmap path
lazy boolean optional (default true) lazy load (only loaded when needed)

Returns

bitmapHandle (userdata): bitmap handle

Examples

local BG = lcd.loadBitmap("gfx/panel.png")   -- file level: loaded once

local function paint(widget)
  if BG then lcd.drawBitmap(0, 0, BG) end
end
  • Returns nil if the file is missing or can't be decoded. Check before drawing.
  • Decoded images use the Lua bitmap memory, which shares a region with the Lua heap. Size images to how they are displayed and release handles (= nil) when a tool closes. See Saving RAM.
  • Transparency (PNG alpha) is supported but costs more.

Used in

Real-world usage

Called 35 times across 6 open-source Ethos Lua projects. A few short excerpts:
local bitmap = lcd.loadBitmap(path)

src/ofs3/lib/utils.lua:113

local icon = lcd.loadBitmap("pgc.png")

lua/frsky/PGC/main.lua:13

if not path then return nil end
local bmp = lcd.loadBitmap(path)

src/dashx/lib/utils.lua:486