What do you want to achieve?
I would like to reliably display a PNG image from a file. I can successfully display just an image from a file. However, when I add another widget (for example’s sake, a rectangle), the image is not reliably displayed. Sometimes (maybe 1 out of every 10-20 times), the image displays correctly.
I am a beginner and often overlook things that may be obvious to those with more experience. Thanks for reading my post and any help or assistance you can provide. I have been pulling my hair out for several days trying to solve this.
What have you tried so far?
- Printing
lv_image_decoder_get_info()output. Regardless of whether the image is successfully displayed or not I getDecoder result=1, header=10 x 10(correct dimensions). - Printing
lv_obj_get_width(img)andlv_obj_get_height(img), after callinglv_obj_update_layout(img). Again, the correct values are listed, even when the image fails to display. - When the rectangle widget is removed, the image displays reliably.
Code to reproduce
fat_init();
bsp_display_start();
bsp_display_lock(-1);
lv_obj_t * scr1 = lv_screen_active();
lv_obj_t * rect = lv_obj_create(scr1);
lv_obj_set_pos(rect, 150, 150);
lv_obj_set_size(rect, 200, 100);
lv_obj_set_style_bg_color(rect, lv_color_hex(0xF17135), LV_STATE_DEFAULT);
lv_obj_t * img = lv_image_create(scr1);
lv_image_set_src(img, "A:/copy.png");
lv_obj_set_pos(img, 220, 220);
lv_obj_set_size(img, 10, 10);
lv_obj_move_foreground(img);
lv_obj_invalidate(img);
bsp_display_unlock();
Screenshot and/or video
Environment
- MCU/MPU/Board: Waveshare ESP32-S3-Touch-AMOLED-1.75C
- LVGL version: 9.6.0
- Decoder: Lode PNG