Set uint32_t image buffer to lv_img object

HI @pete-pjb,

That was it. It worked perfectly. Thank you very much for the help Pete.

See the attached image of working setup.

I have tweaked the code a little bit, but that is essentially the same thing you suggested. See below,

static lv_obj_t * img1 = lv_img_create(lv_scr_act(), NULL);
static uint32_t image_buffer_strong_ref;
static lv_img_dsc_t img_bg;

static void lcd_show_camera_image(uint32_t image_buffer, int width, int height)
{
   image_buffer_strong_ref = image_buffer;

   img_bg.header.always_zero = 0;
   img_bg.header.w = width;
   img_bg.header.h = height;
   img_bg.data_size = width * height * LV_COLOR_SIZE / 8;
   img_bg.header.cf = LV_IMG_CF_TRUE_COLOR;
   img_bg.data = (uint8_t *)image_buffer_strong_ref;
            
   lv_img_set_src(img1, &img_bg);

}

Thanks & Regards,
Prasad.

1 Like