Issue setting image height or width to 1 pixel


After creating an image object, I attempt to set its height (or width depending on the image) to one pixel tall (or wide) via the lv_obj_set_height and lv_obj_set_width functions. This doesn’t work; nothing is shown where the image should be. I can confirm setting height/width to 2 or greater does work as intended.

What MCU/Processor/Board and compiler are you using?

Custom board that uses an STM32L5. Zephyr 3.4

What LVGL version are you using?


What do you want to achieve?

One pixel width / height of images.

What have you tried so far?

I’ve attmpeted to assign a style to the image object, and set the style’s minimum width and height accordingly using lv_style_set_min_width and lv_style_set_min_height but that didn’t work. I also adjusted the custom lvgl_rounder_cb function to ensure enough pixels are being refreshed and that didn’t help.

Code to reproduce

lv_obj_t *Battery_Icon;
lv_obj_t *Setval_Icon;
lv_style_t icon_style;

lv_style_set_min_width(&icon_style, 0);
lv_style_set_min_height(&icon_style, 0);

Battery_Icon = lv_img_create(lv_scr_act());
lv_obj_add_style(Battery_Icon, &icon_style, LV_PART_MAIN);
lv_img_set_src(Battery_Icon, &battery_bar);
lv_obj_set_pos(Battery_Icon, 18, 8);
lv_obj_set_width(Battery_Icon, 1);

Setval_Icon = lv_img_create(lv_scr_act());
lv_obj_add_style(Setval_Icon, &icon_style, LV_PART_MAIN);
lv_obj_move_to_index(Setval_Icon, 1);
lv_img_set_src(Setval_Icon, &setval_top);
lv_obj_set_pos(Setval_Icon, 60, 16);
lv_obj_set_height(Setval_Icon, 1);

I can confirm this is an LVGL code issue, and not an issue in my custom display driver write function, as only zeroes are passed into the display_write function. I can also confirm in my lvgl_set_px_cb function that the lv_color_brightness(color) is always zero, even though it should be greater than zero if I’m setting the width/height to 1.

I can confirm the lv_obj_set_width and lv_obj_set_height functions are working as intended. They are indeed setting the style property correctly (though these functions fail silently if they do fail).

Can someone point me to where in the code the coordinates are set to draw something on the display? I believe this is the next section of code to check.