API Documentation
Auto-generated from img2lv TypeScript definitions.
img2lv
ColorFormat
Color format accepted by the conversion functions. Includes the two special request modes AUTO and OPTIMIZED in addition to all concrete LVGL color formats.
Enumeration Members
A1
A1:
"A1"
A2
A2:
"A2"
A4
A4:
"A4"
A8
A8:
"A8"
AL88
AL88:
"AL88"
ARGB8565
ARGB8565:
"ARGB8565"
ARGB8888
ARGB8888:
"ARGB8888"
ARGB8888_PREMULTIPLIED
ARGB8888_PREMULTIPLIED:
"ARGB8888_PREMULTIPLIED"
AUTO
AUTO:
"AUTO"
Automatically pick the smallest indexed tier (I1/I2/I4/I8) based on the number of distinct colors in the source image.
I1
I1:
"I1"
I2
I2:
"I2"
I4
I4:
"I4"
I8
I8:
"I8"
L8
L8:
"L8"
OPTIMIZED
OPTIMIZED:
"OPTIMIZED"
Like AUTO but also merges redundant transparent palette entries so the palette may shrink to a smaller tier.
RAW
RAW:
"RAW"
RAW_ALPHA
RAW_ALPHA:
"RAW_ALPHA"
RGB565
RGB565:
"RGB565"
RGB565_SWAPPED
RGB565_SWAPPED:
"RGB565_SWAPPED"
RGB565A8
RGB565A8:
"RGB565A8"
RGB888
RGB888:
"RGB888"
UNKNOWN
UNKNOWN:
"UNKNOWN"
XRGB8888
XRGB8888:
"XRGB8888"
CompressMethod
Compression method for the binary payload.
Enumeration Members
LZ4
LZ4:
"LZ4"
NONE
NONE:
"NONE"
RLE
RLE:
"RLE"
ConvertOptions
Options for converting an image to LVGL format.
All fields except cf are optional and fall back to sensible defaults.
Properties
align?
optionalalign?:number
Stride alignment in bytes (any positive integer). Defaults to 1.
background?
optionalbackground?:number
Background color packed as 0xRRGGBB. Defaults to 0.
cf
cf:
"AUTO"|"OPTIMIZED"|"UNKNOWN"|"RAW"|"RAW_ALPHA"|"L8"|"I1"|"I2"|"I4"|"I8"|"A1"|"A2"|"A4"|"A8"|"AL88"|"ARGB8888"|"XRGB8888"|"RGB565"|"ARGB8565"|"RGB565A8"|"RGB888"|"ARGB8888_PREMULTIPLIED"|"RGB565_SWAPPED"
Color format. Accepts any ColorFormat string value (e.g. 'RGB565').
compress?
optionalcompress?:"NONE"|"RLE"|"LZ4"
Compression method. Accepts any CompressMethod string value. Defaults to 'NONE'.
nemaGfx?
optionalnemaGfx?:boolean
Enable Nema GFX compatible output. Defaults to false.
premultiply?
optionalpremultiply?:boolean
Pre-multiply alpha into RGB channels. Defaults to false.
rgb565Dither?
optionalrgb565Dither?:boolean
Enable dithering for RGB565 output. Defaults to false.
DecodeOptions
Options for decoding an LVGL image back to a standard format.
Properties
isCArray?
optionalisCArray?:boolean
Set to true when the input is a C array produced by imageToC. Defaults to false.
imageToBin()
imageToBin(
input,options):Buffer
Convert a common image (PNG, JPEG, WebP, BMP, etc.) into an LVGL v9 binary
blob that can be written straight to a .bin file.
The returned Buffer starts with the 12-byte LVGL image header followed by
the pixel payload (optionally compressed according to options.compress).
Parameters
input
Buffer
options
Returns
Buffer
imageToC()
imageToC(
input,inputName,outputName,options):string
Convert a common image into an LVGL v9 C source file ready for compilation.
inputName is the original filename (used to derive the C variable name
when outputName is not provided). The returned string contains the
complete .c file text including the lv_image_dsc_t descriptor.
Parameters
input
Buffer
inputName
string
outputName
string | null | undefined
options
Returns
string
lvglHeight()
lvglHeight(
input,options?):number
Read the pixel height from an LVGL image header.
Also accepts C array input when options.isCArray is true (not
available on the WASM target).
Parameters
input
Buffer
options?
DecodeOptions | null
Returns
number
lvglToPng()
lvglToPng(
input,options?):Buffer
Decode an LVGL image (binary blob or C array) back to a PNG Buffer.
Accepts either a raw binary blob (12-byte header + payload) or, when
options.isCArray is true, a Buffer containing UTF-8 encoded C source
text produced by imageToC (e.g. Buffer.from(cSource, "utf8")).
Note: C array parsing is not available on the WASM target.
Parameters
input
Buffer
options?
DecodeOptions | null
Returns
Buffer
lvglToRgba()
lvglToRgba(
input,options?):Buffer
Decode an LVGL image to a raw RGBA pixel buffer (4 bytes per pixel, row-major, no padding).
Like lvglToPng, accepts a binary blob or, when options.isCArray is
true, a UTF-8 encoded Buffer of C source text.
Note: C array parsing is not available on the WASM target.
The buffer length equals width × height × 4. Use lvglWidth /
lvglHeight to obtain the dimensions when needed.
Parameters
input
Buffer
options?
DecodeOptions | null
Returns
Buffer
lvglWidth()
lvglWidth(
input,options?):number
Read the pixel width from an LVGL image header.
Also accepts C array input when options.isCArray is true (not
available on the WASM target).
Parameters
input
Buffer
options?
DecodeOptions | null
Returns
number