Online Image Converter
BMP, JPG or PNG to C array or binary

LVGL can use images from C arrays (compiled with the code) or from external devices (e.g. from SD card) to display them on your TFT display. Learn how to create images for the graphics library.

shape image

With this free online image converter tool you can create C arrays or raw binary files from images. PNG, JPG and BMP files and multiple output color formats are supported.
The result files are compatible with LVGL but with minor modification you can use them with other graphics libraries.

How to use the image converter?

  1. Choose an Image (png, jpg, or bmp)
  2. Give a Name to the output file. E.g. "wallpaper1"
  3. Specify the Color format. Scroll down for details.
  4. Set the output format: C array, Binary RGB332, Binary RGB565, Binary RGB888
  5. Enable Dithering is you want. More about Dithering.
  6. Click the Convert button and to download the converted image.

How to use the generated file in LVGL?

  • For C arrays
    1. Copy the result C file into your LVGL project
    2. In a C file of your application declare the image as: LV_IMG_DECLARE(my_image_name);
    3. Set the image for an lv_img object: lv_img_set_src(img1, &my_image_name);
  • For external binary files (e.g. SD card)
    1. Set up a new driver. To learn more read the Documentation.
    2. Set the image for an lv_img object: lv_img_set_src(img1, "S:/path/to/image");

Alpha byte Add a 8 bit Alpha value to every pixel
Chroma keyed Make LV_COLOR_TRANSP (lv_conf.h) pixels to transparent


Dithering of True color images

Color format details

True color, True color with alpha, True color chroma key

If the Output format is C array then the following pixel formats will be included in the array: RGB888, RGB565, BGR565 (bytes swapped) and RGB332. The corresponding format will be enabled according to LV_COLOR_DEPTH and LV_COLOR_16_SWAP settings in lv_conf.h. If Dithering is appiled the pixels will be slightly modified on non RGB888 formats to prevent color banding.

If you need a Binary output then you need to select the pixel format you need. Dithering can be applied here as well

If True color with alpha is chosen then an extra alpha byte will be added to every pixel resulting in pixels formats like: ARGB8888, ARGB8565, ARGB8332. PNG format is recommended with 32 bit (ARGB8888) colors.

True color chroma key will result the same file as True color except it will be marked as Chroma keyed which means the LV_COLOR_TRANSP (lv_conf.h) pixles will be rendered as transparent. JPG should be avoided because it doesn't keep the colors as they are. There for LV_COLOR_TRANSP pixels can change.

Indexed 2/4/16/256 colors

A palette will be generated at beginning of the result array with 2/4/16/256 colors and pixels will be coded on 1/2/4/8 bits. For the best quality, the uploaded image already should be in index format too. You can use GIMP to do the conversion in Image->Mode->Indexed menu. Here you can set the number of colors and enabled dithering as well. In LVGL these images will be always Chroma keyed.

Alpha only 2/4/16/256 shades

Only the alpha channel is taken into account and stored in 1/2/4/8 bits to result 2/4/16/256 shades. Pixels with alpha = 0 will be transparent. The other pixel's color will style.image.color and their alpha will be set according to the original'pixels alpha. The image has to contain alpha channel. E.g. ARGB8888

Raw, Raw with alpha, Raw chroma key

The image is not interpreted pixel-by-pixel just converted to an array as it is. It is useful for example to convert a PNG file to a C array to store the PNG image in flash and use LVGL's Image decoder interface

Subscribe to Newsletters

Subscribe to our newsletters to no miss any news about LVGL. We will send maximum 1-2 mails/month.

Contact with us

Do you have any question? Have a great idea? Want to leave feedback?

We are keen on to hear about you! Just fill the form to contact with us.

Reach us quickly
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.