Extract draw_bitmap from draw_glyph.

This commit is contained in:
Jared Boone 2016-02-03 10:33:54 -08:00
parent ceef8d32d3
commit 5d0b5d427a
2 changed files with 25 additions and 8 deletions

View File

@ -299,20 +299,29 @@ void ILI9341::draw_pixels(
io.lcd_write_pixels(colors, count);
}
void ILI9341::draw_bitmap(
const ui::Point p,
const ui::Size size,
const uint8_t* const pixels,
const ui::Color foreground,
const ui::Color background
) {
lcd_start_ram_write(p, size);
const size_t count = size.w * size.h;
for(size_t i=0; i<count; i++) {
const auto pixel = pixels[i >> 3] & (1U << (i & 0x7));
io.lcd_write_pixel(pixel ? foreground : background);
}
}
void ILI9341::draw_glyph(
const ui::Point p,
const ui::Glyph& glyph,
const ui::Color foreground,
const ui::Color background
) {
lcd_start_ram_write(p, glyph.size());
const size_t count = glyph.w() * glyph.h();
const auto pixels = glyph.pixels();
for(size_t i=0; i<count; i++) {
const auto pixel = pixels[i >> 3] & (1U << (i & 0x7));
io.lcd_write_pixel(pixel ? foreground : background);
}
draw_bitmap(p, glyph.size(), glyph.pixels(), foreground, background);
}
void ILI9341::scroll_set_area(

View File

@ -65,6 +65,14 @@ public:
draw_pixels(r, colors.data(), colors.size());
}
void draw_bitmap(
const ui::Point p,
const ui::Size size,
const uint8_t* const data,
const ui::Color foreground,
const ui::Color background
);
void draw_glyph(
const ui::Point p,
const ui::Glyph& glyph,