I have already decoded jpg file to jpg-decoded data,
and link the jpg-decoded data to manual static lv_img_dsc_t src_dsc,
and use this src_dsc for lv_img’s obj.
It can display well on screen, however, I wish to move the code to
add new the littlevgl’s image decoder by lv_img_decoder_t
like png_decoder example.
The question is,
in function decoder_info() , thelv_img_header_t * header (paremeter 3)
for jpg , header->cf should be set by
header->cf = LV_IMG_CF_RAW;
or by
header->cf = LV_IMG_CF_TRUE_COLOR;
By manual static lv_img_dsc_t src_dsc, I set by LV_IMG_CF_TRUE_COLOR,
it’s work well.
But by lv_img_decoder_t , in decoder_info(), which one is suitable?
Thank you.
What MCU/Processor/Board and compiler are you using?
ESP32
What do you want to achieve?
jpg decoder by add new lv_img_decoder_t to littlevgl,
instead of by static lv_img_dsc_t src_dsc.
In the end, LV_IMG_CF_RAW and LV_IMG_CF_TRUE_COLOR are the same. RAW is used in to indicate that an image source has raw data (e.g. JPG as it is) and it can’t be processed by the built-in image decoders. However, when it’s being drawn it is assumed that the raw image is already decoded to a plain RGB map.
Thank you for updated.
Now can change to the other image-file.
However when I test by set
#define LV_IMG_CACHE_DEF_SIZE 3
and set period for changing between any image-file to 1 second.
But the speed of displaying on TFT is not the same rate.
It seems not read from the 3 image-caches?
Screenshot and/or video
Code to reproduce
lv_obj_t * img;
const char* img_files[] = { "/sd/pictures/jgp_file.jpg" ,
"/sd/pictures/bmp_file.bmp",
"/sd/pictures/png_file.png" };
uint8_t img_index = 0;
time_t timer;
void setup(){
Serial.begin(115200); Serial.println();
lvgl_setup();
img = lv_img_create(lv_scr_act(), NULL);
}
void loop(){
lvgl_loop();
if( millis() >= timer ){
// period 1 second for changing to the other image-file
timer = millis() + 1000;
lv_img_set_src(img, img_files[img_index] );
img_index = (++img_index)%3;
}
}
What do you want to achieve?
Any image-file format that has displayed on TFT,
when display again , the image-catches are used for displaying at the same rate.