How to config JPG Decoder's header->cf in decoder_info()?

Description

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.

What have you tried so far?

Code to reproduce

Screenshot and/or video

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.

1 Like

Thank you. Then I used LV_IMG_CF_RAW as your advice.

Another question.
I tried to set

#define LV_IMG_CACHE_DEF_SIZE 3

and test by the following simple code.

lv_obj_t *img;

void setup() {
  Serial.begin(115200); Serial.println();
  lvgl_setup();

  img = lv_img_create(lv_scr_act(), NULL);
  lv_img_set_src(img, "/sd/pictures/picture_01.jpg");

}

bool state = false;
time_t timer;

void loop() {
  lvgl_loop();
  if( millis() > timer ) {
    timer = millis() + 1000;
    if(state) {
      lv_img_set_src(img, "/sd/pictures/picture_01.jpg");
    }else{
      lv_img_set_src(img, "/sd/pictures/picture_02.jpg");
    }
    state = !state;
  }
}

The result on TFT’s screen, display only picture_01.jpg.
How to add any api for img object can change to the other picture?

( It also can’t change between png file.)

What do you want to achieve?

Lvgl can use multiple img-catchs for speeding up previous image-decoding,
when changing between any image-file by lv_img_set_src()

Ups, it was a bug in the library.
I’ve fixed in the master branch here.

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.

I’ve updated master again. I hope it will work now.

The image chache wasn’t deeply tested with files. Good to know that it will be tested now :slight_smile:

1 Like

Very fast update.
Thank you very much. : )

Is it working? :slight_smile:

1 Like

It seems fine now, thank you.

1 Like