img_decoder: handle error messages as placeholder.

This commit is contained in:
Gabor Kiss-Vamosi
2019-06-24 05:59:31 +02:00
parent 189ca15d7c
commit d67f84bc1a
2 changed files with 9 additions and 2 deletions

View File

@@ -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*/

View File

@@ -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;