/lv_lib_lodepng

PNG decoder for LittlevGL

Primary LanguageCMIT LicenseMIT

lv_png_decoder

Allow the use of PNG images in LittlevGL. This implementation uses lodepng library.

Get started

  • Download or clone this repository
  • Include the library: #include "lv_lib_lodepng/lv_lodepng.h"
  • Initalize the decocer with lv_lodepng_init()
  • Test with the following code:
    LV_IMG_DECLARE(png_decoder_test);
    lv_obj_t * img = lv_img_create(lv_scr_act(), NULL);
    lv_img_set_src(img, &png_decoder_test);

Use PNG images from file

lodepng uses the POSIX filesystem API. PNG files can be used like this:

lv_img_set_src(img, "./lv_lib_lodepng/png_decoder_test.png");

Note that the path of the file might be different.

Use PNG images from flash

To store a PNG images in flash it needs to be converted to C array with Online Image converter. Choose Raw with alpha Color format and C array Output format. Copy the result C array to your project and use it like this:

    LV_IMG_DECLARE(my_test_img);
    lv_obj_t * img = lv_img_create(lv_scr_act(), NULL);
    lv_img_set_src(img, &my_test_img);

Learn more

To learn more about the PNG decoder itself read this blog post

To learn more about the Image decoder interface of LittlevGL read the realevant part of the documentation.