Can PNG decoder using the LVGL display buffer?

Dear Friend:
I have a board which running lvgl-7…I already immigrate the latest png decoder into the project.and I changed the memory request and free by below …but the issue is the buffer of PNG decoding need really big…like 3screen widthscreen height…is there a way I can directly usie the lvgl disp buffer for decoding and display directly

void* lodepng_malloc(size_t size) {
if(size > LODEPNG_MAX_ALLOC) return 0;
return lv_mem_alloc(size);


If the PNG image the bottom most widget theoretically you can pass LVGL’s draw buffer (if it’s large enough to hold the whole PNG image) to the PNG decoder but it’d be super hacky. :slight_smile:

There are some extra things to consider: always redraw the whole screen, create a custom image widget for it, etc.

Thanks for reply…you know there is no other way to support 360*360 screen …only the memory is lvgl draw buffer…good thing,I just need show the whole picture…so put a simple lvgl object below the picture ,maybe work…If I got time ,will try to do that …

So ,if some contributor have time maybe consider one line by line decoder and put into it as the previous topic you dicussed

1 Like

I wrote a wrapper for a streaming decoder called Pngle.
The way it is written you’ll need 1 x screen_width x screen_height x color_depth + ~43k for streaming decompression.

See here:

Thanks a lot ,but you know "1 x screen_width x screen_height x color_depth " is still very big ,for example a 360*360 screen …so better is modify the PNG decoder and let the LVGL draw buffer at your final target…means maybe need a lot of change about lvgl core …so …we will see

I think the big deal would be if there were a PNG decoder that can decompress an arbitrary area.

Dear kisegabor:
After go through some code , I think it is possiable to do that like bmp decoder using line by line decoder…as png is using lzw alegothm ,if there are enough memory for the dictionary…I don’t have time recently ,maybe try later.