当前位置:网站首页>Example of lvgl display picture

Example of lvgl display picture

2022-07-05 15:24:00 Neo Wordsworth

adopt   Online image conversion tool   Get a picture file , The data extracted here is convenient for understanding the display of pictures ( This data can be transmitted over the network or Bluetooth )

uint8_t myimg_map[] = {
    0x00, 0x00, 0xff, 0xff,
    0x00, 0x00, 0x00, 0x00,

    0xfe, 0x7f,
    0xfd, 0xbf,
    0xc0, 0x03,
    0xd7, 0xdb,
    0xcf, 0xeb,
    0xdf, 0xf3,
    0x9e, 0x79,
    0x5d, 0xba,
    0x5d, 0xba,
    0x9e, 0x79,
    0xdf, 0xfb,
    0xcf, 0xe3,
    0xd7, 0xdb,
    0xc0, 0x03,
    0xfd, 0xbf,
    0xfe, 0x7f,
};
void test1(){
    static lv_img_dsc_t myimg;

    myimg.header.cf = LV_IMG_CF_INDEXED_1BIT;
    myimg.header.always_zero = 0;
    myimg.header.reserved = 0;
    myimg.header.w = 16;
    myimg.header.h = 16;
    myimg.data_size = 40;
    myimg.data = myimg_map;

    lv_obj_t * icon = lv_img_create(lv_scr_act());
    lv_obj_center(icon);
    lv_img_set_src(icon, &myimg);

//#define LV_MY_RECOLOR 1 // Note here, the original red 
#if LV_MY_RECOLOR
    static lv_style_t img_style;
    lv_style_init(&img_style);
    lv_style_set_img_recolor(&img_style,lv_color_hex(0x0000ff));
    lv_style_set_img_recolor_opa(&img_style,255);
    lv_obj_add_style(icon, &img_style, 0);
#endif
}

After running, such a small picture is displayed

If enable defines LV_MY_RECOLOR

You can recolor , Original red , Recolor to blue

(LV_IMG_CF_INDEXED_1BIT Before the data 3 Bits represent colors : blue 、 green 、 red )

 

 

原网站

版权声明
本文为[Neo Wordsworth]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/186/202207051457025153.html