From d67f84bc1a477ea7623cf92c5a74f7aef6a67591 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Mon, 24 Jun 2019 05:59:31 +0200 Subject: [PATCH] img_decoder: handle error messages as placeholder. --- src/lv_draw/lv_draw_img.c | 8 ++++++-- src/lv_draw/lv_img_decoder.c | 3 +++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/lv_draw/lv_draw_img.c b/src/lv_draw/lv_draw_img.c index 084834f0f..a22348f2f 100644 --- a/src/lv_draw/lv_draw_img.c +++ b/src/lv_draw/lv_draw_img.c @@ -455,10 +455,14 @@ static lv_res_t lv_img_draw_core(const lv_area_t * coords, const lv_area_t * mas bool chroma_keyed = lv_img_color_format_is_chroma_keyed(cdsc->dsc.header.cf); bool alpha_byte = lv_img_color_format_has_alpha(cdsc->dsc.header.cf); - + if(cdsc->dsc.error_msg != NULL) { + LV_LOG_WARN("Image draw error"); + lv_draw_rect(coords, mask, &lv_style_plain, LV_OPA_COVER); + lv_draw_label(coords, mask, &lv_style_plain, LV_OPA_COVER, cdsc->dsc.error_msg, LV_TXT_FLAG_NONE, NULL, -1, -1, NULL); + } /* The decoder open could open the image and gave the entire uncompressed image. * Just draw it!*/ - if(cdsc->dsc.img_data) { + else if(cdsc->dsc.img_data) { lv_draw_map(coords, mask, cdsc->dsc.img_data, opa, chroma_keyed, alpha_byte, style->image.color, style->image.intense); } /* The whole uncompressed image is not available. Try to read it line-by-line*/ diff --git a/src/lv_draw/lv_img_decoder.c b/src/lv_draw/lv_img_decoder.c index be52f4815..3dcb98b27 100644 --- a/src/lv_draw/lv_img_decoder.c +++ b/src/lv_draw/lv_img_decoder.c @@ -134,7 +134,10 @@ lv_res_t lv_img_decoder_open(lv_img_decoder_dsc_t * dsc, const void * src, const LV_LL_READ(LV_GC_ROOT(_lv_img_defoder_ll), d) { res = LV_RES_INV; + dsc->error_msg = NULL; + dsc->img_data = NULL; dsc->decoder = d; + if(d->open_cb) res = d->open_cb(d, dsc); if(res == LV_RES_OK) break;