How to display a picture on a monochrome screen?

void lv_example_img_1(void)

    lv_obj_t * img1 = lv_img_create(lv_scr_act());

    lv_obj_set_style_img_opa(img1, 255, LV_PART_MAIN|LV_STATE_DEFAULT);
    lv_img_set_src(img1, &set_map);
    lv_obj_align(img1, LV_ALIGN_CENTER, 0, 00);
    lv_obj_set_size(img1, 100, 100);

No reply?

No question no reply. LVGL dont manage send to displays. For this is called flushcb and you need write code for show here. For example conv 16 bit color to mono …


Please give some more context.
Have you already gotten the display working? Is the issue just with the image?

I’ve fixed this issue because of the font array pointer reference error. Does the size of the image control depend on the actual size of the picture?

Not exactly. You can set the lv_img object size to whatever you want, but setting it to the dimensions of the image is probably the best option. If you set the lv_img object size to half that of the actual image, you will only see half the image.

with lv_img_set_zoom you can enlarge/decrease the size of the image in LVGL. However, if you only need a static image it might be best to manually scale down that image before exporting it to a C array.

Great, thank you for your help!

Hi, Tinus

I want to invert the color of the image, but no matter how I modify the style, it won’t take effect. The background of the square should be removed. How can I solve this problem?

void gui_load_set_screen(void)

  lv_obj_t * img1 = lv_img_create(lv_scr_act());
  lv_obj_set_style_bg_color(img1, lv_color_black(),0);
  lv_obj_set_style_bg_opa(img1,LV_OPA_100, 0);
  lv_img_set_src(img1, &set_img);
  lv_obj_align(img1, LV_ALIGN_CENTER, 0, 0);
  lv_obj_set_size(img1, 200, 200);     


Hello again,

I believe the issue is that the image has been incorrectly converted using the image converter tool.

To make use of the transparent background of the image, you need to use some setting with ALPHA in the name.

I know for a fact that TRUE_COLOR_ALPHA works.
(I think I have even used that exact icon myself before!)

You might also try CF_RAW_ALPHA or one of the CF_ALPHA_X options to reduce file size, seeing as the image is only black and white (and some grey pixels for anti-aliasing!)

I have modified the image output format, some can be displayed and some cannot be displayed, but the effect is similar to CF_TRUE_ COLOR . Is this related to the format (non bitmap) and background color of the raw image?

Converting a .png file with transparency using TRUE_COLOR_ALPHA should work.

This ticket is monochrome screen and you end with true color? Try read docu about display drivers and image recolor