almindor / mipidsi

MIPI Display Serial Interface unified driver
MIT License
108 stars 47 forks source link

Fix DrawTarget::fill_contiguous #100

Closed rfuest closed 4 months ago

rfuest commented 5 months ago

This PR fixes the implementation of the fill_contiguous method in the DrawTarget trait if area overlaps the edge of the framebuffer.

Here is an example that demonstrates the problem:

let logo = tinybmp::Bmp::from_slice(LOGO).unwrap();

for anchor in [
    AnchorPoint::TopLeft,
    AnchorPoint::TopRight,
    AnchorPoint::Center,
    AnchorPoint::BottomLeft,
    AnchorPoint::BottomRight,
] {
    Image::with_center(&logo, tft.bounding_box().anchor_point(anchor))
        .draw(&mut tft)
        .unwrap();
}

Current master version: Before

After this PR is applied: After

rfuest commented 4 months ago

I've updated the PR to also work on architectures with 16 bit usize by conditionally compiling a different implementation of nth and take in this case.