Inky 7.3: Support dithering of arbitrary colours.

`create_pen` returns an int with the most significant byte set to indicate it is an RGB888 colour.

Pen values without the most significant byte set are treated as palette entries and handled normally.
pull/685/head
Phil Howard 2023-02-23 11:08:03 +00:00
rodzic 63de02016f
commit 3e0cd28876
2 zmienionych plików z 13 dodań i 5 usunięć

Wyświetl plik

@ -40,6 +40,10 @@ namespace pimoroni {
r((__builtin_bswap16(c) & 0b1111100000000000) >> 8),
g((__builtin_bswap16(c) & 0b0000011111100000) >> 3),
b((__builtin_bswap16(c) & 0b0000000000011111) << 3) {}
constexpr RGB(uint c) :
r((c >> 16) & 0xff),
g((c >> 8) & 0xff),
b(c & 0xff) {}
constexpr RGB(int16_t r, int16_t g, int16_t b) : r(r), g(g), b(b) {}
constexpr RGB operator+ (const RGB& c) const {return RGB(r + c.r, g + c.g, b + c.b);}
@ -539,8 +543,7 @@ namespace pimoroni {
bool cache_built = false;
std::array<uint8_t, 16> candidates;
RGB src_color;
RGB565 color;
uint color;
IDirectDisplayDriver<uint8_t> &driver;
PicoGraphics_PenInky7(uint16_t width, uint16_t height, IDirectDisplayDriver<uint8_t> &direct_display_driver);

Wyświetl plik

@ -7,15 +7,20 @@ namespace pimoroni {
this->pen_type = PEN_INKY7;
}
void PicoGraphics_PenInky7::set_pen(uint c) {
color = c & 0x7;
color = c;
}
void PicoGraphics_PenInky7::set_pen(uint8_t r, uint8_t g, uint8_t b) {
color = RGB(r, g, b).to_rgb888() | 0x010101;
}
int PicoGraphics_PenInky7::create_pen(uint8_t r, uint8_t g, uint8_t b) {
return 0;
return RGB(r, g, b).to_rgb888() | 0x010101;
}
void PicoGraphics_PenInky7::set_pixel(const Point &p) {
driver.write_pixel(p, color);
if ((color & 0x010101) == 0x010101) {
set_pixel_dither(p, RGB(color));
} else {
driver.write_pixel(p, color & 0x07);
}
}
void PicoGraphics_PenInky7::set_pixel_span(const Point &p, uint l) {
driver.write_pixel_span(p, l, color);