Comments (4)
@W-Mai I just saw that the docs of the image caching is outdated here. Do you have time to update it?
Oh, sure, let me be in charge of this.
from lvgl.
Does the UI still work after changing the image?
Please try these:
- call
lv_obj_invalidate(imgobj_qr1)
- call
lv_image_cache_drop("C:/decoded_image.png");
- set
LV_CACHE_DEF_SIZE 0
inlv_conf.h
- try saving the image with a different name
from lvgl.
Thank you for the good advice. I did the test as you suggested and got results like this.
Does the UI still work after changing the image
Yes, the UI and other objects still work normally.
call
lv_obj_invalidate(imgobj_qr1)
I have tried doing this
...
lv_image_set_src(imgobj_qr1, "C:/decoded_image.png");
lv_obj_align(imgobj_qr1, LV_ALIGN_CENTER, 0, 0);
lv_obj_invalidate(imgobj_qr1); // <---
But still nothing has changed.
call
lv_image_cache_drop("C:/decoded_image.png");
It works, but needs to call lv_image_cache_drop("C:/decoded_image.png");
before creating an image like this.
lv_image_cache_drop("C:/decoded_image.png"); //<--
if(lv_obj_is_valid(imgobj_qr1)){lv_obj_delete_async(imgobj_qr1); Serial.println("del old1------------------------");}
imgobj_qr1 = lv_image_create(lv_screen_active()); Serial.println("create new1");
...
lv_image_set_src(imgobj_qr1, "C:/decoded_image.png");
lv_obj_align(imgobj_qr1, LV_ALIGN_CENTER, 0, 0);
set
LV_CACHE_DEF_SIZE
0 in lv_conf.h`
I originally set this to
#define LV_MEM_SIZE (3072U * 1024U) // Allocate on PSRAM
#define LV_CACHE_DEF_SIZE (1500U * 1024U)
#define LV_IMAGE_HEADER_CACHE_DEF_CNT (512U * 1024U)
When changed to
#define LV_MEM_SIZE (3072U * 1024U) // Allocate on PSRAM
#define LV_CACHE_DEF_SIZE 0
#define LV_IMAGE_HEADER_CACHE_DEF_CNT 0
It works too. But it takes a very long time to draw and the file is constantly being read (for large images).
try saving the image with a different name
It works too (when LV_CACHE_DEF_SIZE
and LV_IMAGE_HEADER_CACHE_DEF_CNT
are not 0), but images in the old cache are not cleared when changing to new images. Then the cache will be full when changing the image to a new one within 3-4 times.
In conclusion, I think your suggestion call lv_image_cache_drop("C:/decoded_image.png");
is the best solution.
And this would be great if in the documentation https://docs.lvgl.io/master/libs/lodepng.html it was suggested to add lv_image_cache_drop(imageSrc);
before loading new images.
Thanks again for the great solution to this problem. 😊
from lvgl.
Awesome! 🎉
Actually it's related to images in general, because LVGL caches images by file name (or pointer in case of variables). So if you change the content of the image you need to tell LVGL to re-cache it.
@W-Mai I just saw that the docs of the image caching is outdated here. Do you have time to update it?
from lvgl.
Related Issues (20)
- Recoloring in V9 HOT 1
- ESP32 Rotate doesn't work HOT 3
- ESP32-3248S035C with GT911 touch chip, arduino demo compile error HOT 16
- How can LVGL be better used on wayland/ DRM-enabled SoCs?
- have the C++ version image convert tool and font generate tool? HOT 10
- lv_demo_widgets example in windows, get stuck and break! HOT 15
- Rotate Base object (lv_obj) v9 HOT 15
- Error: failed to map framebuffer device to memory: Invalid argument HOT 3
- LV_EVENT_CLICKED should only be fired if the release takes place over the same object where the press happened HOT 3
- Default fonts not clear on red background HOT 4
- Span elements not printing properly HOT 10
- Display bug HOT 2
- get_x_aligned returns wrong value in case of percentage unit HOT 6
- STM32 Baremetal application only Renders to part of the screen HOT 5
- Change TileView Scroll animation speed HOT 3
- why the picture pixel blinking when running lvgl demo HOT 1
- Number and logic buttons in physical buttons
- Bengali string display abnormal using freetype lib HOT 2
- Cannot play custom gif in v9.1 HOT 6
- lvgl draws artefacts after button click HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lvgl.