How to show the dynamically image

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

What MCU/Processor/Board and compiler are you using?

ARM M33

What LVGL version are you using?

8.4

What do you want to achieve?

Show the image

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:

pTextImage->pImageData = EXmalloc(pTextImage->pBitmap->width * pTextImage->pBitmap->height * 3);
	for (i = 0; i < pTextImage->pBitmap->width * pTextImage->pBitmap->height * 3;) {		
		pTextImage->pImageData[i ++] = pTextImage->pBitmap->color & 0xff;
		pTextImage->pImageData[i ++] = pTextImage->pBitmap->color >> 8;		
		pTextImage->pImageData[i ++] = pTextImage->pBitmap->bitmap_addr[color_counter ++];
	}

	pTextImage->pImg_dsc->header.cf = LV_IMG_CF_TRUE_COLOR_ALPHA;
	pTextImage->pImg_dsc->header.always_zero = 0;
	pTextImage->pImg_dsc->header.reserved = 0;
	pTextImage->pImg_dsc->header.w = pTextImage->pBitmap->width;
	pTextImage->pImg_dsc->header.h = pTextImage->pBitmap->height;
	pTextImage->pImg_dsc->data_size = pTextImage->pBitmap->width * pTextImage->pBitmap->height * 3;
	pTextImage->pImg_dsc->data = pTextImage->pImageData;

	pTextImage->pFontImage = lv_img_create(parent);
	lv_img_set_src(pTextImage->pFontImage, pTextImage->pImg_dsc);
	lv_obj_set_pos(pTextImage->pFontImage, pTextImage->pBitmap->x, pTextImage->pBitmap->y);
	lv_obj_set_size(pTextImage->pFontImage, pTextImage->pBitmap->width, pTextImage->pBitmap->height);

Screenshot and/or video

If possible, add screenshots and/or videos about the current state.
微信图片_20250415141040

The “Runner” image is I loaded from RAM use Jlink, so that means the data is right. The second picture is it show in the tft.
So I do not know which part is wrong.

@kisvegabor Could you help me?

Why not Font text Label? Your data or flush code is bad.

because I need more than 30 thousand words and 10 sizes, so I use TTF to dynamically create, LVGL font is too large.

Hello,
It looks to me like your data is not being sent to this display on time or just improperly altogether. Have you tried running a demo? If they also have this issue, it has nothing to do with showing the image.


This screen is more complex than the testing screen, but everything is right, I use same way.
The problem screen, is a content, I show a content and show the words on it.

Try get more info, how is your flash capacity, how font sizes you require etc.
Try you use compress parameter for font generator ? Font Converter — LVGL

If I use ttf, only 2MB. If I use lvgl font, more than 40MB. I need show the Caller name and music name, in english, chinese, japanese, and so on.

Ok then i mean you search and know FreeType Support — LVGL 9.3 documentation
, but back to your issue.
Is very simmilar to +1 error in flush width… Mayby your generated and used width differ, then image is draw every line shifted… Check or try manipulate

	pTextImage->pImg_dsc->header.w = pTextImage->pBitmap->width;
	pTextImage->pImg_dsc->header.h = pTextImage->pBitmap->height;

FreeType is need too much memory, I tried it in other MCU. So we develop our ttf platform, it can reduce the RAM requeirnment. It can output the grey 8bit for a word or a character. We use it in many MCU platform with LVGL, but this strange thing is first time.
I can try the FreeType on this MCU.

And yesterday I found a strange thing:


I create two image objects, and one is show right another is wrong. I use lv_img_set_src change the wrong object image data to the right one. But the wrong object still wrong.
MY code:
ShowUTF8TextImage(&m_CurrentEarPhoneImage, &g_NameArray[m_MACShowCounter][0], 0, guider_ui.screen_cont_Setup, 1);
ShowUTF8TextImage(&m_BTMacArray[m_MACShowCounter], &g_NameArray[m_MACShowCounter][0], 0, guider_ui.screen_cont_Setup, 0);
lv_img_set_src(m_BTMacArray[m_MACShowCounter].pFontImage, m_CurrentEarPhoneImage.pImg_dsc);
lv_obj_clear_flag(m_BTMacArray[m_MACShowCounter].pFontImage, LV_OBJ_FLAG_HIDDEN);

lv_ft_info_t g_Lvgl_Font_Info;
g_Lvgl_Font_Info.name = NULL;
g_Lvgl_Font_Info.mem = (void*)0x8201000;
g_Lvgl_Font_Info.mem_size = 2591496;
g_Lvgl_Font_Info.weight = 24;
g_Lvgl_Font_Info.style = FT_FONT_STYLE_NORMAL;

lv_style_init(&g_Lvgl_Font_Style);
lv_style_set_text_font(&g_Lvgl_Font_Style, g_Lvgl_Font_Info.font);
lv_style_set_text_align(&g_Lvgl_Font_Style, LV_TEXT_ALIGN_CENTER);

memset(word, 0, sizeof(word));
word[0] = ‘0’;
word[1] = ‘.’;
word[2] = ‘0’;
//lv_obj_set_style_text_font(guider_ui.screen_label_Speed, &lv_customer_font_BLOODWAX_40, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_add_style(guider_ui.screen_label_Speed, &g_Lvgl_Font_Style, 0);
lv_label_set_text(guider_ui.screen_label_Speed, word);

But I get this error

[Error] (0.442, +442) get_glyph_dsc_cb_cache: SBitCache_Lookup error (in lv_freetype.c line #294)
[Error] (0.451, +9) get_glyph_dsc_cb_cache: SBitCache_Lookup error (in lv_freetype.c line #294)
[Error] (0.460, +9) get_glyph_dsc_cb_cache: SBitCache_Lookup error (in lv_freetype.c line #294)
[Error] (0.470, +10) get_glyph_dsc_cb_cache: SBitCache_Lookup error (in lv_freetype.c line #294)
[Error] (0.480, +10) get_glyph_dsc_cb_cache: SBitCache_Lookup error (in lv_freetype.c line #294)
[Error] (0.489, +9) get_glyph_dsc_cb_cache: SBitCache_Lookup error (in lv_freetype.c line #294)
[Error] (0.499, +10) get_glyph_dsc_cb_cache: SBitCache_Lookup error (in lv_freetype.c line #294)

I fix that, the problem is TFT tearing up. I see the tearing up is tilting at first time.
But for the Freetype, colud you help me?