mirror of
https://github.com/lvgl/lvgl.git
synced 2025-01-28 07:03:00 +08:00
fix(draw): stride handling for RGB565A8 images
This commit is contained in:
parent
fd0ebf01e6
commit
b8356ebe6c
@ -34,6 +34,7 @@ typedef struct {
|
||||
static lv_res_t decode_indexed_line(lv_color_format_t color_format, const lv_color32_t * palette, lv_coord_t y,
|
||||
lv_coord_t w_px, const uint8_t * in, lv_color32_t * out);
|
||||
|
||||
static uint32_t img_width_to_stride(lv_img_header_t * header);
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
@ -93,9 +94,7 @@ lv_res_t lv_img_decoder_get_info(const void * src, lv_img_header_t * header)
|
||||
if(d->info_cb) {
|
||||
res = d->info_cb(d, src, header);
|
||||
if(res == LV_RES_OK) {
|
||||
if(header->stride == 0) {
|
||||
header->stride = header->w * lv_color_format_get_size(header->cf);
|
||||
}
|
||||
if(header->stride == 0) header->stride = img_width_to_stride(header);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -143,9 +142,7 @@ lv_res_t lv_img_decoder_open(lv_img_decoder_dsc_t * dsc, const void * src, lv_co
|
||||
res = decoder->info_cb(decoder, src, &dsc->header);
|
||||
if(res != LV_RES_OK) continue;
|
||||
|
||||
if(dsc->header.stride == 0) {
|
||||
dsc->header.stride = dsc->header.w * lv_color_format_get_size(dsc->header.cf);
|
||||
}
|
||||
if(dsc->header.stride == 0) dsc->header.stride = img_width_to_stride(&dsc->header);
|
||||
|
||||
dsc->decoder = decoder;
|
||||
res = decoder->open_cb(decoder, dsc);
|
||||
@ -483,3 +480,14 @@ static lv_res_t decode_indexed_line(lv_color_format_t color_format, const lv_col
|
||||
}
|
||||
return LV_RES_OK;
|
||||
}
|
||||
|
||||
|
||||
static uint32_t img_width_to_stride(lv_img_header_t * header)
|
||||
{
|
||||
if(header->cf == LV_COLOR_FORMAT_RGB565A8) {
|
||||
return header->w * 2;
|
||||
}
|
||||
else {
|
||||
return header->w * lv_color_format_get_size(header->cf);
|
||||
}
|
||||
}
|
||||
|
@ -76,12 +76,14 @@ LV_ATTRIBUTE_FAST_MEM static void draw_letter_cb(lv_draw_unit_t * draw_unit, lv_
|
||||
#endif
|
||||
}
|
||||
else if(glyph_draw_dsc->format == LV_DRAW_LETTER_BITMAP_FORMAT_A8) {
|
||||
lv_area_t mask_area = *glyph_draw_dsc->letter_coords;
|
||||
mask_area.x2 = mask_area.x1 + lv_draw_buf_width_to_stride(lv_area_get_width(&mask_area), LV_COLOR_FORMAT_A8) - 1;
|
||||
lv_draw_sw_blend_dsc_t blend_dsc;
|
||||
lv_memzero(&blend_dsc, sizeof(blend_dsc));
|
||||
blend_dsc.color = glyph_draw_dsc->color;
|
||||
blend_dsc.opa = glyph_draw_dsc->opa;
|
||||
blend_dsc.mask_buf = glyph_draw_dsc->bitmap;
|
||||
blend_dsc.mask_area = glyph_draw_dsc->letter_coords;
|
||||
blend_dsc.mask_area = &mask_area;
|
||||
blend_dsc.blend_area = glyph_draw_dsc->letter_coords;
|
||||
blend_dsc.mask_res = LV_DRAW_SW_MASK_RES_CHANGED;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user