mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2025-08-20 04:37:48 +00:00
Add ability to draw text with a transparent background
(cherry picked from commit a15da2e136147b31ab53058871815c8eb759576a)
This commit is contained in:
@@ -606,6 +606,9 @@ void ILI9341::draw_bitmap(
|
|||||||
const ui::Color foreground,
|
const ui::Color foreground,
|
||||||
const ui::Color background
|
const ui::Color background
|
||||||
) {
|
) {
|
||||||
|
// Not a transparent background
|
||||||
|
if (ui::Color::magenta().v!=background.v)
|
||||||
|
{
|
||||||
lcd_start_ram_write(p, size);
|
lcd_start_ram_write(p, size);
|
||||||
|
|
||||||
const size_t count = size.width() * size.height();
|
const size_t count = size.width() * size.height();
|
||||||
@@ -614,6 +617,26 @@ void ILI9341::draw_bitmap(
|
|||||||
io.lcd_write_pixel(pixel ? foreground : background);
|
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++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ILI9341::draw_glyph(
|
void ILI9341::draw_glyph(
|
||||||
const ui::Point p,
|
const ui::Point p,
|
||||||
|
Reference in New Issue
Block a user