Add ability to draw text with a transparent background

(cherry picked from commit a15da2e136147b31ab53058871815c8eb759576a)
This commit is contained in:
heurist1 2023-02-28 19:00:11 +00:00
parent 86203f090f
commit b549d3a4f1

View File

@ -606,12 +606,35 @@ void ILI9341::draw_bitmap(
const ui::Color foreground,
const ui::Color background
) {
lcd_start_ram_write(p, size);
// Not a transparent background
if (ui::Color::magenta().v!=background.v)
{
lcd_start_ram_write(p, size);
const size_t count = size.width() * size.height();
for(size_t i=0; i<count; i++) {
const auto pixel = pixels[i >> 3] & (1U << (i & 0x7));
io.lcd_write_pixel(pixel ? foreground : background);
const size_t count = size.width() * size.height();
for(size_t i=0; i<count; i++) {
const auto pixel = pixels[i >> 3] & (1U << (i & 0x7));
io.lcd_write_pixel(pixel ? foreground : background);
}
}
else
{
int x = p.x();
int y = p.y();
int maxX = x + size.width();
const size_t count = size.width() * size.height();
for(size_t i=0; i<count; i++) {
const auto pixel = pixels[i >> 3] & (1U << (i & 0x7));
if (pixel) {
draw_pixel(ui::Point(x,y), foreground);
}
// Move to the next pixel
x++;
if (x>=maxX){
x = p.x();
y++;
}
}
}
}