lvgl / lv_lib_png Goto Github PK
View Code? Open in Web Editor NEWPNG decoder for LVGL
License: MIT License
PNG decoder for LVGL
License: MIT License
Hello
Im trying to load the basic example on a stm32f429 discovery board.
Im not doing anything unusual,
lv_init();
tft_init();
lv_png_init();
.
.
.
LV_IMG_DECLARE(png_decoder_test);
lv_obj_t * imgpng = lv_img_create(lv_scr_act(), NULL);
lv_img_set_src(imgpng, &png_decoder_test);
lv_obj_align(imgpng, NULL, LV_ALIGN_CENTER, 0, 0);
The only thing I get on the screen is:
No
data
I just have one image, but I've #define LV_IMG_CACHE_DEF_SIZE 2
Is there anything else I need to think about?
Im using "7faf20592598e7f891cf2aceca32bbe6ff5fc36c"
I have made another thread to call lv_img_btn_set_src with png files as an event interruption,but it shows nothing.However it works well with imgbtn api in main thread or img api in both main and second thread.
Hello guys,
I noticed something weird, if I load my png alone (only the image on the screen) it loads fast (esp32 with 4mgs external ram) but if I add a canvas on top, it just gets to run very slow, I understand the canvas is this transparent piece of component that can be used to draw "primitives" to screen, but I am finding it quite difficult to make it faster with the canvas, can I draw a square on top of the PNG image without using the canvas?
I tried #define LV_COLOR_CHROMA_KEY lv_color_hex(0x000000) /black as background and not draw/ and it takes no effect.
my main screen's background is black and there're some overlapped area between image buttons as bellow ing:
Hello, guys, I have a doubt, if I follow the instructions to load data from the .c file, it loads, then if I provide the file directly with bytes, it shows me the "No data" message but in the log it says, it recognizes the file type, this is the snipet:
uint8_t tmp_img[20869];
File f = SPIFFS.open("/test.png", "r");
Serial.print("Size:");
Serial.println(f.size());
if (f) {
Serial.print("Bytes read:");
Serial.println(f.readBytes((char *)tmp_img, f.size()));
f.close();
}
const lv_img_header_t png_decoder_test_map_header2 = {
LV_IMG_CF_RAW_ALPHA,
0,
2,
200,
150
};
const lv_img_dsc_t png_decoder_test2 = {
png_decoder_test_map_header2,
20869,
tmp_img
};
lv_img_set_src(img1, &png_decoder_test2);
It does provide the bytes from what I can see and the logs say:
Size:20869
Bytes read:20869
Info: lv_img_set_src: `LV_IMG_SRC_VARIABLE` type found (lv_img.c #180 lv_img_set_src())
Data x48
Data y118
Info: image draw: cache miss, close and reuse an entry (lv_img_cache.c #120 _lv_img_cache_open())
Warn: Image draw cannot open the image resource (lv_img_cache.c #135 _lv_img_cache_open())
Warn: Image draw error (lv_draw_img.c #88 lv_draw_img())
So, right afer it extracts the bytes it just goes directly to "No data"
Hello
I'm using esp32(arduino framework) + lvgl + lv_lib_lodepng.
when I try to show a png image it doesn’t work. it only shows a white rectangle with a “No data” text on the top left corner. I tried to Use PNG images from flash and file as instructed in the README file of the library and none of them works. the problem is only with png files because when i use a true color image it works fine.
I also Enabled the log module on LV_LOG_LEVEL_WARN level and the following lines are printed in the console:
.pio\libdeps\esp32dev\lvgl\src\lv_draw\lv_img_cache.c@131->fnn: _lv_img_cache_open ->Image draw cannot open the image resource .pio\libdeps\esp32dev\lvgl\src\lv_draw\lv_draw_img.c@87->fnn: lv_draw_img ->Image draw error
also the same code works in vs simulator and the problem only occurs when I’m using esp32.
Code to reproduce
void setup() { display_init(); touch_init(); lv_fs_if_init(); 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); } void loop() { lv_task_handler(); delay(5); }
the lv_png_init() is inside the display_init() function.
Screenshot and/or video
I use LVGL's file system API, it work fine when i transform the img to bin file,but when i open png file directly,it display “nodata”.
I Initalize the decocer with lv_png_init() and add #define LV_PNG_USE_LV_FILESYSTEM 1.
It printf: ERROR 48:empty input buffer given to decoder. Maybe caused by non-existing file?
Attempted to build using pio and I run into this error:
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/m5stack-core2.html
PLATFORM: Espressif 32 (3.2.1) > M5Stack Core2
HARDWARE: ESP32 240MHz, 6.25MB RAM, 16MB Flash
DEBUG: Current (esp-prog) External (esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa)
PACKAGES:
- framework-espidf 3.40201.210513 (4.2.1)
- tool-cmake 3.16.4
- tool-esptoolpy 1.30000.201119 (3.0.0)
- tool-idf 1.0.1
- tool-mconf 1.4060000.20190628 (406.0.0)
- tool-mkspiffs 2.230.0 (2.30)
- tool-ninja 1.9.0
- toolchain-esp32ulp 1.22851.191205 (2.28.51)
- toolchain-xtensa32 2.80400.210211 (8.4.0)
Reading CMake configuration...
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 0 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
Compiling .pio\build\core2foraws\components\lv_lib_png\lv_png.o
components\lv_lib_png\lv_png.c:31:37: warning: 'struct _lv_img_decoder_t' declared inside parameter list will not be visible outside of this definition or declaration
static lv_res_t decoder_info(struct _lv_img_decoder_t * decoder, const void * src, lv_img_header_t * header);
^~~~~~~~~~~~~~~~~
components\lv_lib_png\lv_png.c: In function 'lv_png_init':
components\lv_lib_png\lv_png.c:54:37: warning: passing argument 2 of 'lv_img_decoder_set_info_cb' from incompatible pointer type [-Wincompatible-pointer-types]
lv_img_decoder_set_info_cb(dec, decoder_info);
^~~~~~~~~~~~
In file included from components\core2forAWS\tft\lvgl/lvgl/src/lv_core/../lv_draw/lv_draw_img.h:16,
from components\core2forAWS\tft\lvgl/lvgl/src/lv_core/lv_obj.h:29,
from components\core2forAWS\tft\lvgl/lvgl/lvgl.h:32,
from components\lv_lib_png\lv_png.c:12:
components\core2forAWS\tft\lvgl/lvgl/src/lv_core/../lv_draw/lv_img_decoder.h:201:85: note: expected 'lv_img_decoder_info_f_t' {aka 'unsigned char (*)(struct _lv_img_decoder *, const void *, struct <anonymous> *)'} but argument is of type 'lv_res_t (*)(struct _lv_img_decoder_t *, const void *, lv_img_header_t *)' {aka 'unsigned char (*)(struct _lv_img_decoder_t *, const void *, struct <anonymous> *)'}
void lv_img_decoder_set_info_cb(lv_img_decoder_t * decoder, lv_img_decoder_info_f_t info_cb);
~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~
components\lv_lib_png\lv_png.c: At top level:
components\lv_lib_png\lv_png.c:70:37: warning: 'struct _lv_img_decoder_t' declared inside parameter list will not be visible outside of this definition or declaration
static lv_res_t decoder_info(struct _lv_img_decoder_t * decoder, const void * src, lv_img_header_t * header)
^~~~~~~~~~~~~~~~~
components\lv_lib_png\lv_png.c:70:17: error: conflicting types for 'decoder_info'
static lv_res_t decoder_info(struct _lv_img_decoder_t * decoder, const void * src, lv_img_header_t * header)
^~~~~~~~~~~~
components\lv_lib_png\lv_png.c:31:17: note: previous declaration of 'decoder_info' was here
static lv_res_t decoder_info(struct _lv_img_decoder_t * decoder, const void * src, lv_img_header_t * header);
^~~~~~~~~~~~
components\lv_lib_png\lv_png.c:31:17: warning: 'decoder_info' used but never defined
components\lv_lib_png\lv_png.c:70:17: warning: 'decoder_info' defined but not used [-Wunused-function]
static lv_res_t decoder_info(struct _lv_img_decoder_t * decoder, const void * src, lv_img_header_t * header)
^~~~~~~~~~~~
Compiling .pio\build\core2foraws\lwip\lwip\src\core\pbuf.o
Compiling .pio\build\core2foraws\lwip\lwip\src\core\raw.o
Compiling .pio\build\core2foraws\lwip\lwip\src\core\stats.o
Compiling .pio\build\core2foraws\lwip\lwip\src\core\sys.o
Compiling .pio\build\core2foraws\lwip\lwip\src\core\tcp.o
Compiling .pio\build\core2foraws\lwip\lwip\src\core\tcp_in.o
*** [.pio\build\core2foraws\components\lv_lib_png\lv_png.o] Error 1
hello,
I'm using esp32 + lvgl + lv_lib_lodepng,
but when I use a png more 20K , it would shows "memory allocation failed", where can I change for making the memory allocation bigger ?
Hello, I use the lv_lib_png have a problem.
LVGL version: 7.0.
My PNG image is RGBA8888, and the LV_COLOR_DEPTH is set to 16 because the device only supports 16bit pix. when trying to display some image with gradient color, there is a picture distortion problem.
original image is:
in fact, displaying image is:
I find the problem is in function "convert_color_depth" in lv_png.c. In this function, RGB888 is converted to RGB 565, and low bits of R byte、G byte and B byte are dropped, which creates such a problem.
So,there is a better way to deal with it. Thank you for your replying!
If I show two 720p png,the decoder performance is terrible,the fps almost half lower than just show one picture,but if I replace one of it with a c array it works well.I'm sure the chip I'm using is powerful enouth to decode this so I wonder if there is some problem such as memory allowcation or some options I didn't notice? Can you give some advice about how to locate this problem.
I am testing (lv_lib_png) performance and heap allocation.
I implemented my allocator (tracing/logging mallocs) to test software (basically the lodepng library) and enabling the MEM_BLOCK.
I found there is a missing FreeMem call which will result in memory leak (here)
I know is not lvgl code, so i went to lodepng site to report issue.
I found that this code is no longer exist.
In fact, I found that lv_lib_png is using "20180611" release. lodepng is now "20201017"
Regards,
i am trying to open .png file from SD card and display on LCD but it shows image with white background with nodata text.
how to resolve that?
maybe it should be:
#elif LV_COLOR_DEPTH == 8
lv_color32_t * img_argb = (lv_color32_t*)img;
lv_color_t c;
uint32_t i;
for(i = 0; i < px_cnt; i++) {
c = lv_color_make(img_argb[i].ch.blue, img_argb[i].ch.green, img_argb[i].ch.red);
img[i2 + 1] = img_argb[i].ch.alpha;
img[i2 + 0] = c.full;
}
Hello, I use the lv_lib_png
have a problem.
LVGL version: 8.0.1
First, I need to state steps before asking the question:
lv_fs_if
in my project, and I am sure that it is available. Because I can load my qingtian.bin
used with lv_img_set_src
.#define LV_PNG_USE 1 #define LV_PNG_USE_LV_FILESYSTEM 1
at the end of 'lv_cong.h'.But Clion(platformio) remind #define LV_PNG_USE 1 #define LV_PNG_USE_LV_FILESYSTEM 1 is never used.
lv_obj_img
in my project."No data"
in weather_img
obj, It is wrong.So, I don`t know what happend? Where is the problem?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.