Png decoder partitial decoding for small ram target

for the exiting official png decoder, it uses too many ram and draws the whole thing.

but for some mcu with less ram, we may want to decode & draw a PNG line-by-line. there is an existing png decoder for arduino platform: PNGdec, it requires less than 50kB ram.

and we tried it on a lvgl powered project X-TRACK, it works. here is a temporary repo for the modification. the decoder work-flow as following:

  • lv_draw_img.c | lv_img_draw_core() =>
    | decoder->draw_lbl_cb
    | lv_lib_lpng\lv_lpng.cpp | decoder_draw_lbl() => PNGDec => lv_draw_map()

as we can see, this patch is not so well implementation, it will modify the lvgl core code.
so, is there any simple and clean method to apply this?

any suggestion are welcome.

1 Like

I would suggest starting with the official decoder library and modifying lv_png.c in the spots where it calls lodepng APIs.

1 Like

If you do end up getting this to work in the manner I described, we might be interested in this upstream as well. The ability to do line-by-line decoding is definitely missing in the lodepng-based implementation (e.g. with lodepng, you need at least 300-600KB of free RAM just to display a 320x480 image).

(cc @kisvegabor, @amirgon)

I agree.

We can change lodepng if there is better candidate.

lv_lib_split_jpg might be useful too. It decodes the image in small blocks.

Note that, if the image is decoded line-by-line it can’t be rotated or zoomed.

1 Like

why not try to apply this to offical way…we are really suffered with such big memory consuming for decoding