Important: unclear posts may not receive useful answers.
Before posting
- Get familiar with Markdown to format and structure your post
- Be sure to update lvgl from the latest version from the
master
branch.- Be sure you have checked the FAQ and read the relevant part of the documentation.
- If applicable use the Simulator to eliminate hardware related issues.
Delete this section if you read and applied the mentioned points.
Description
My TFT screen resolution is 292240, but my camera data is 320 240.
I want to show the camera data on the screen.
What MCU/Processor/Board and compiler are you using?
ARM M4 288MHz
What LVGL version are you using?
8.3
What do you want to achieve?
Show the Image and cut some parts
What have you tried so far?
Code to reproduce
Add a code snippet which can run in the simulator. It should contain only the relevant code that compiles without errors when separated from your main code base.
The code block(s) should be formatted like:
m_UVC_dsc_t.header.cf = LV_IMG_CF_TRUE_COLOR;
m_UVC_dsc_t.header.always_zero = 0;
m_UVC_dsc_t.header.reserved = 0;
m_UVC_dsc_t.header.w = 320;
m_UVC_dsc_t.header.h = 240;
m_UVC_dsc_t.data_size = 320 * 240 * 2;
m_pConUVC = lv_obj_create(guider_ui.screen);
lv_obj_set_pos(m_pConUVC, 0, 0);
lv_obj_set_size(m_pConUVC, 296, 240);
lv_obj_set_scrollbar_mode(m_pConUVC, LV_SCROLLBAR_MODE_ON);
lv_obj_clear_flag(m_pConUVC, LV_OBJ_FLAG_HIDDEN);
lv_obj_set_style_border_width(m_pConUVC, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_radius(m_pConUVC, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_bg_opa(m_pConUVC, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_bg_color(m_pConUVC, lv_color_hex(0xffffff), LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_bg_grad_dir(m_pConUVC, LV_GRAD_DIR_NONE, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_pad_top(m_pConUVC, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_pad_bottom(m_pConUVC, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_pad_left(m_pConUVC, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_pad_right(m_pConUVC, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_shadow_width(m_pConUVC, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
m_pUVCImage = lv_img_create(m_pConUVC);
lv_obj_set_size(m_pUVCImage, 320, 240);
lv_obj_align(m_pUVCImage, LV_ALIGN_CENTER, 0, 0);
lv_obj_set_style_pad_top(m_pUVCImage, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_pad_bottom(m_pUVCImage, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_pad_left(m_pUVCImage, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_pad_right(m_pUVCImage, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_border_width(m_pUVCImage, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
And In Camera callback:
unsigned short* pd;
m_isUVCUpdate = 1;
m_UVC_dsc_t.data = (unsigned char*)pdata;
pd = (unsigned short*)pdata;
for (int i = 0; i < 320 * 240; i ++) {
pd[i] = swap_short_endian(pd[i]);
}
lv_img_set_src(m_pUVCImage, &m_UVC_dsc_t);
Now I can show the camera data, but it have a strange retangle. How to delete it?
And another question, how to support LSB RGB data? now you can see I need swap each data, it is not good solution.
Screenshot and/or video
If possible, add screenshots and/or videos about the current state.