1
0
mirror of https://github.com/lvgl/lvgl.git synced 2025-01-14 06:42:58 +08:00

fix(image): fix the image decoder if LV_BIN_DECODER_RAM_LOAD == 0 (#5892)

Signed-off-by: Neo Xu <neo.xu1990@gmail.com>
Co-authored-by: Neo Xu <neo.xu1990@gmail.com>
This commit is contained in:
Gabor Kiss-Vamosi 2024-03-18 12:25:24 +01:00 committed by GitHub
parent 5a4f0247a0
commit 715dcf0e79
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 14 additions and 2 deletions

View File

@ -399,7 +399,7 @@ lv_result_t lv_bin_decoder_get_area(lv_image_decoder_t * decoder, lv_image_decod
int32_t w_px = lv_area_get_width(full_area);
uint8_t * img_data = NULL;
lv_draw_buf_t * decoded = NULL;
uint32_t offset = 0;
uint32_t offset = dsc->src_type == LV_IMAGE_SRC_FILE ? sizeof(lv_image_header_t) : 0; /*Skip the image header*/
/*We only support read line by line for now*/
if(decoded_area->y1 == LV_COORD_MIN) {
@ -443,7 +443,6 @@ lv_result_t lv_bin_decoder_get_area(lv_image_decoder_t * decoder, lv_image_decod
offset += decoded_area->y1 * dsc->header.stride;
offset += decoded_area->x1 * bpp / 8; /*Move to x1*/
if(dsc->src_type == LV_IMAGE_SRC_FILE) {
offset += sizeof(lv_image_header_t); /*File image starts with image header*/
buf = lv_malloc(len);
LV_ASSERT_NULL(buf);
if(buf == NULL)
@ -884,6 +883,7 @@ static lv_result_t decode_alpha_only(lv_image_decoder_t * decoder, lv_image_deco
static lv_result_t decode_compressed(lv_image_decoder_t * decoder, lv_image_decoder_dsc_t * dsc)
{
#if LV_BIN_DECODER_RAM_LOAD
uint32_t rn;
uint32_t len;
uint32_t compressed_len;
@ -989,6 +989,13 @@ static lv_result_t decode_compressed(lv_image_decoder_t * decoder, lv_image_deco
}
return res;
#else
LV_UNUSED(decompress_image);
LV_UNUSED(decoder);
LV_UNUSED(dsc);
LV_LOG_ERROR("Need LV_BIN_DECODER_RAM_LOAD to be enabled");
return LV_RESULT_INVALID;
#endif
}
static lv_result_t decode_indexed_line(lv_color_format_t color_format, const lv_color32_t * palette, int32_t x,

View File

@ -22,8 +22,10 @@ static const char * color_formats[] = {
static const char * compressions[] = {
"UNCOMPRESSED",
#if LV_BIN_DECODER_RAM_LOAD == 1
"RLE",
"LZ4"
#endif
};
static const char * modes[] = {
@ -282,6 +284,9 @@ void test_image_formats(void)
for(unsigned mode = 0; mode <= 3; mode++) {
bool rotate = mode & 0x02;
bool recolor = mode & 0x01;
#if LV_BIN_DECODER_RAM_LOAD == 0
if(rotate) continue; /* Transform relies on LV_BIN_DECODER_RAM_LOAD to be enabled */
#endif
/*Loop compressions array and do test.*/
for(unsigned i = 0; i < sizeof(compressions) / sizeof(compressions[0]); i++) {
char reference[256];