This LVGL image converter turns any PNG, JPG or BMP into a ready-to-compile lv_image_dsc_t (LVGL v9) or lv_img_dsc_t (LVGL v8) C array — or an LVGL .bin file — with every colour format the official converter offers: RGB565, RGB565A8, RGB888, ARGB8888, XRGB8888, L8, indexed I1–I8 with a palette, and alpha masks A1–A8. Pick little- or big-endian byte order, turn dithering on or off, and watch a live preview of the quantised result before you download. It is an online LVGL image converter that runs 100% in your browser, so confidential product UI art never leaves your machine.
LVGL v9 vs v8: what the converter generates
LVGL is the Light and Versatile Graphics Library behind most modern embedded GUIs on ESP32, STM32, RP2040 and NXP/Renesas MCUs. A static image is an image descriptor: a header plus a byte array. The two major versions disagree about the header, and pasting one into the other is the number-one source of a blank screen or an image header magic mismatch log line:
- LVGL v9 —
lv_image_dsc_twith.header.magic = LV_IMAGE_HEADER_MAGIC,.header.cf = LV_COLOR_FORMAT_*,.header.w/.h,.header.strideand.data_size. Shown withlv_image_create()/lv_image_set_src(). - LVGL v8 —
lv_img_dsc_twith.header.cf = LV_IMG_CF_*,.header.always_zero,.header.reserved,.header.w/.h. Shown withlv_img_create()/lv_img_set_src(). The pixel layout of true-colour images depends onLV_COLOR_DEPTH, so the generated file includes an#errorguard that fires if yourlv_conf.hdoes not match.
Choose the version in the first dropdown; the colour-format list changes to the enums that version actually has.
Which colour format to pick
| Format | Bytes / px | Use it for |
|---|---|---|
RGB565 (v8: TRUE_COLOR, 16-bit) | 2 | Opaque photos and backgrounds on ILI9341, ST7789, ST7735 and most 16-bit TFTs. The default. |
RGB565A8 (v9) / TRUE_COLOR_ALPHA (v8, 16-bit) | 3 | Sprites and icons with transparency on a 16-bit build. v9 stores a colour plane followed by an alpha plane; v8 interleaves the alpha byte. |
ARGB8888 / XRGB8888 (v8: 32-bit TRUE_COLOR_ALPHA / TRUE_COLOR) | 4 | Builds with LV_COLOR_DEPTH 32, or when you need full 8-bit alpha. Stored B,G,R,A in memory. |
| RGB888 (v9) | 3 | 24-bit panels; no alpha. |
| I1 / I2 / I4 / I8 indexed | ⅛ – 1 (+ palette) | Logos and flat UI art with few colours. A 2-, 4-, 16- or 256-entry ARGB8888 palette is generated by median-cut and the pixels become bit-packed indices — often a 4–16× flash saving over RGB565. Transparent pixels get a reserved palette entry. |
| A1 / A2 / A4 / A8 alpha | ⅛ – 1 | Single-colour icons you recolour at run time with lv_obj_set_style_image_recolor(). Take the alpha from the PNG's transparency, or from dark pixels for a black-on-white source. |
| L8 (v9) | 1 | 8-bit grayscale. |
Byte order, dithering and size
Byte order. LVGL keeps RGB565 little-endian; if your display controller wants the two bytes swapped, pick Big-endian / swapped. On LVGL v8 that corresponds to LV_COLOR_16_SWAP 1 (the output checks it); on v9 the driver usually swaps in the flush callback with lv_draw_sw_rgb565_swap(), and LVGL 9.3+ has LV_COLOR_FORMAT_RGB565_SWAPPED.
Dithering. Quantising a smooth photo to 65K colours (or a 16-colour palette) produces banding. With Dither on, Floyd–Steinberg error diffusion spreads the rounding error to neighbouring pixels so gradients stay smooth — the same option the LVGL converter calls “dither images”. Switch it off for pixel art and flat icons.
Size. By default every image keeps its original pixel size, like the official tool. Choose Resize to the canvas to scale, letterbox or stretch into a preset such as 320×240 for an ILI9341 background. Drop several files at once and each becomes its own descriptor in the output (and its own .bin).
Show the image in LVGL
Generate the descriptor above (named my_img), save it as my_img.c next to your sources, then:
// LVGL v9
#include "lvgl.h"
LV_IMAGE_DECLARE(my_img);
void show_logo(void) {
lv_obj_t * img = lv_image_create(lv_screen_active());
lv_image_set_src(img, &my_img);
lv_obj_center(img);
}
// LVGL v8 equivalent
LV_IMG_DECLARE(my_img);
lv_obj_t * img = lv_img_create(lv_scr_act());
lv_img_set_src(img, &my_img);
In ESP-IDF add the .c file to idf_component_register(SRCS ...); in PlatformIO or Arduino just drop it in src/. Because the array is const (and tagged LV_ATTRIBUTE_LARGE_CONST) it lives in flash and costs no RAM beyond LVGL's draw buffer.
Using the .bin file from a filesystem
The .bin download is the LVGL binary image format — the header (12 bytes on v9, 4 on v8) followed by exactly the bytes in the C array. Store it on SPIFFS, LittleFS or an SD card, enable a file-system driver in lv_conf.h (LV_USE_FS_STDIO, LV_USE_FS_POSIX, LV_USE_FS_FATFS …) and load it at run time:
lv_image_set_src(img, "S:/images/my_img.bin");
Binary images keep large artwork out of the firmware so you can update them over OTA without reflashing, at the cost of a small decode latency on first draw.
Keeping flash usage down
An RGB565 image costs width × height × 2 bytes: a 320×240 ILI9341 background is 153,600 bytes. The byte count is shown live under the preview, so you can compare formats on your actual image. Typical wins: switch flat-colour UI art to I4 (16 colours, 8× smaller than RGB565), icons you tint at run time to A4 or A2, and scale photos down to the size they are displayed at rather than letting LVGL scale a bigger source.
Driving a plain SSD1306 OLED instead of a colour GUI? Use the u8g2 converter or the classic image2cpp converter. For e-ink panels see the e-paper converter, and for text, the GFX font converter.