mirror of
https://github.com/lvgl/lvgl.git
synced 2025-01-28 07:03:00 +08:00
chore(decoder): call image post process directly (#5371)
Signed-off-by: Xu Xingliang <xuxingliang@xiaomi.com>
This commit is contained in:
parent
67f9997184
commit
dd42600e24
@ -135,20 +135,16 @@ static lv_result_t decoder_open(lv_image_decoder_t * decoder, lv_image_decoder_d
|
||||
return LV_RESULT_INVALID;
|
||||
}
|
||||
|
||||
/*Stride check and adjustment accordingly*/
|
||||
if(args && args->stride_align) {
|
||||
uint32_t expected = lv_draw_buf_width_to_stride(decoded->header.w, decoded->header.cf);
|
||||
if(expected != decoded->header.stride) {
|
||||
LV_LOG_INFO("Convert PNG stride to %" LV_PRId32, expected);
|
||||
lv_draw_buf_t * aligned = lv_draw_buf_adjust_stride(decoded, expected);
|
||||
lv_draw_buf_destroy(decoded);
|
||||
if(aligned == NULL) {
|
||||
LV_LOG_ERROR("png stride adjust failed");
|
||||
return LV_RESULT_INVALID;
|
||||
}
|
||||
lv_draw_buf_t * adjusted = lv_image_decoder_post_process(dsc, decoded);
|
||||
if(adjusted == NULL) {
|
||||
lv_draw_buf_destroy(decoded);
|
||||
return LV_RESULT_INVALID;
|
||||
}
|
||||
|
||||
decoded = aligned;
|
||||
}
|
||||
/*The adjusted draw buffer is newly allocated.*/
|
||||
if(adjusted != decoded) {
|
||||
lv_draw_buf_destroy(decoded);
|
||||
decoded = adjusted;
|
||||
}
|
||||
|
||||
dsc->decoded = decoded;
|
||||
|
@ -182,32 +182,24 @@ static lv_result_t decoder_open(lv_image_decoder_t * decoder, lv_image_decoder_d
|
||||
}
|
||||
|
||||
lv_draw_buf_t * decoded = decode_png_data(png_data, png_data_size);
|
||||
|
||||
if(dsc->src_type == LV_IMAGE_SRC_FILE) lv_free((void *)png_data);
|
||||
|
||||
if(!decoded) {
|
||||
LV_LOG_WARN("Error decoding PNG\n");
|
||||
if(png_data != NULL) {
|
||||
lv_free((void *)png_data);
|
||||
}
|
||||
return LV_RESULT_INVALID;
|
||||
}
|
||||
|
||||
/*Stride check and adjustment accordingly*/
|
||||
if(args && args->stride_align) {
|
||||
uint32_t expected = lv_draw_buf_width_to_stride(decoded->header.w, decoded->header.cf);
|
||||
if(expected != decoded->header.stride) {
|
||||
LV_LOG_INFO("Convert PNG stride to %" LV_PRId32, expected);
|
||||
lv_draw_buf_t * aligned = lv_draw_buf_adjust_stride(decoded, expected);
|
||||
lv_draw_buf_destroy(decoded);
|
||||
if(aligned == NULL) {
|
||||
LV_LOG_ERROR("png stride adjust failed");
|
||||
return LV_RESULT_INVALID;
|
||||
}
|
||||
|
||||
decoded = aligned;
|
||||
}
|
||||
lv_draw_buf_t * adjusted = lv_image_decoder_post_process(dsc, decoded);
|
||||
if(adjusted == NULL) {
|
||||
lv_draw_buf_destroy(decoded);
|
||||
return LV_RESULT_INVALID;
|
||||
}
|
||||
|
||||
if(dsc->src_type == LV_IMAGE_SRC_FILE) {
|
||||
lv_free((void *)png_data);
|
||||
/*The adjusted draw buffer is newly allocated.*/
|
||||
if(adjusted != decoded) {
|
||||
lv_draw_buf_destroy(decoded);
|
||||
decoded = adjusted;
|
||||
}
|
||||
|
||||
dsc->decoded = decoded;
|
||||
|
Loading…
x
Reference in New Issue
Block a user