Lv_img_design: Method not capable of display single pixel width/height (Dev 6.1)

Description

The lv_img_design method cannot display objects that have a width or height that is only 1 pixel.

What MCU/Processor/Board and compiler are you using?

STM32F4xx KEIL uVision MDK 5.27 using ARMCC 5.06 update 6 toolchain.

What do you experience?

Method lv_img_design is unable to draw single pixel width/height objects. Method exits early before drawing object.

What do you expect?

lv_img_design in lv_img.c should be able to draw objects with width/height that is only 1 pixel.

Code to reproduce

Coordinate check is using < when it should check for <= for x and y loop over image pixels. This causes it to not draw images that are only 1 pixel width or height.

for(; cords_tmp.y1 < coords.y2; cords_tmp.y1 += ext->h, cords_tmp.y2 += ext->h) {
    cords_tmp.x1 = coords.x1;
    cords_tmp.x2 = coords.x1 + ext->w - 1;
    for(; cords_tmp.x1 < coords.x2; cords_tmp.x1 += ext->w, cords_tmp.x2 += ext->w) {
        lv_draw_img(&cords_tmp, mask, ext->src, style, opa_scale);
    }
}

Changing code to use <= fixes issue.

for(; cords_tmp.y1 <= coords.y2; cords_tmp.y1 += ext->h, cords_tmp.y2 += ext->h) {
    cords_tmp.x1 = coords.x1;
    cords_tmp.x2 = coords.x1 + ext->w - 1;
    for(; cords_tmp.x1 <= coords.x2; cords_tmp.x1 += ext->w, cords_tmp.x2 += ext->w) {
        lv_draw_img(&cords_tmp, mask, ext->src, style, opa_scale);
    }
}
1 Like

Can you send the fixes from both of your posts as a pull request? You can put them together in one if that is easier.

1 Like

Will submit a request as soon as I have a few free minutes :slight_smile:

Pull Request sent and accepted. Thx :slight_smile:

1 Like

Thank you! :slight_smile: