Set uint32_t image buffer to lv_img object

Hi @prasad ,

Okay it looks like the camera buffer should be RGB888 format it may or may not work with LVGL directly but we should try and get at least something to display first and see whether it needs reformatting later…

I think something along these lines should work which is pretty similar to your first posting…

static lv_obj_t * img1 = lv_img_create(lv_scr_act(), NULL);

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

    static lv_img_dsc_t img_bg = {
            .header.always_zero = 0,
            .header.w = width,
            .header.h = height,
            .data_size = width * height * LV_COLOR_SIZE / 8,
            .header.cf = LV_IMG_CF_TRUE_COLOR,
            .data = (uint8_t*)image_buffer
            };

    lv_img_set_src(img1, &img_bg);
}

The assumption for the above code is the image buffer is global or a reserved area for dma.
Note also the img_bg & img1 variables need to be static so they are always available and not destroyed when exiting the function. Also lv_img_set_src() function needs the address of the img_bg variable passed hence the ‘&’ prefix in the call.

I would give this a try and see what happens, I would expect something on the screen even if it’s not the correct image.

Kind Regards,

Pete

3 Likes