Inky 7.3: Dither pixel spans, move RGB flag out of RGB888.

pull/685/head
Phil Howard 2023-02-23 13:31:45 +00:00
rodzic 80fab77270
commit a5b0633469
1 zmienionych plików z 10 dodań i 4 usunięć

Wyświetl plik

@ -10,22 +10,28 @@ namespace pimoroni {
color = c; color = c;
} }
void PicoGraphics_PenInky7::set_pen(uint8_t r, uint8_t g, uint8_t b) { void PicoGraphics_PenInky7::set_pen(uint8_t r, uint8_t g, uint8_t b) {
color = RGB(r, g, b).to_rgb888() | 0x010101; color = RGB(r, g, b).to_rgb888() | 0x7f000000;
} }
int PicoGraphics_PenInky7::create_pen(uint8_t r, uint8_t g, uint8_t b) { int PicoGraphics_PenInky7::create_pen(uint8_t r, uint8_t g, uint8_t b) {
return RGB(r, g, b).to_rgb888() | 0x010101; return RGB(r, g, b).to_rgb888() | 0x7f000000;
} }
int PicoGraphics_PenInky7::create_pen_hsv(float h, float s, float v) { int PicoGraphics_PenInky7::create_pen_hsv(float h, float s, float v) {
return RGB::from_hsv(h, s, v).to_rgb888() | 0x010101; return RGB::from_hsv(h, s, v).to_rgb888() | 0x7f000000;
} }
void PicoGraphics_PenInky7::set_pixel(const Point &p) { void PicoGraphics_PenInky7::set_pixel(const Point &p) {
if ((color & 0x010101) == 0x010101) { if ((color & 0x7f000000) == 0x7f000000) {
set_pixel_dither(p, RGB(color)); set_pixel_dither(p, RGB(color));
} else { } else {
driver.write_pixel(p, color & 0x07); driver.write_pixel(p, color & 0x07);
} }
} }
void PicoGraphics_PenInky7::set_pixel_span(const Point &p, uint l) { void PicoGraphics_PenInky7::set_pixel_span(const Point &p, uint l) {
if ((color & 0x7f000000) == 0x7f000000) {
for(auto x = 0u; x < l; x++) {
set_pixel_dither(p + Point(x, 0), RGB(color));
}
return;
}
driver.write_pixel_span(p, l, color); driver.write_pixel_span(p, l, color);
} }
void PicoGraphics_PenInky7::get_dither_candidates(const RGB &col, const RGB *palette, size_t len, std::array<uint8_t, 16> &candidates) { void PicoGraphics_PenInky7::get_dither_candidates(const RGB &col, const RGB *palette, size_t len, std::array<uint8_t, 16> &candidates) {