How to scale and display a JPEG image in lv_img?


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


What LVGL version are you using?


What do you want to achieve?

My screen size is 480x640, and I have an image with a size of 480x640 and a format of JPEG stored in FATFS. I want to display it in an lv_img component of size 240x320. In other words, I need a functionality to scale the image.

What have you tried so far?

I tried the following two functions: lv_obj_set_style_transform_zoom and lv_obj_set_style_transform_zoom, but neither of them seems to work. After calling these functions, the lv_img component on the screen does not display anything. Could it be that these functions do not support images from FATFS?

//	lv_obj_set_style_transform_zoom(img_1, 128, LV_PART_MAIN);
//	lv_img_set_zoom(img_1, 128);
	lv_img_set_src(img_1, "3:/IMAGE1.jpg");

How can I scale the jpeg image in fatfs?Thanks a lot.

Did you decode the jpeg data? Have you used the lv_img_conv or some other method?

Yes,jpeg and sjpg can be displayed in lv_img when LV_USE_SJPG is enabled.
What’s lv_img_conv?It seems I don’t have this component in my version.

I might find the answer:

Scaling JPG is not supported either in v7 or v8

I wonder if there are some other methods too.