PicoGraphics: Add RGB565 alpha blending support.

patch-img-open_file
Phil Howard 2024-07-11 09:40:37 +01:00 zatwierdzone przez Phil Howard
rodzic 5ce870fd3f
commit 03ada256ed
2 zmienionych plików z 13 dodań i 0 usunięć

Wyświetl plik

@ -532,6 +532,9 @@ namespace pimoroni {
}
void frame_convert(PenType type, conversion_callback_func callback) override;
void set_pixel_alpha(const Point &p, const uint8_t a) override;
bool supports_alpha_blend() override {return true;}
};
class PicoGraphics_PenRGB888 : public PicoGraphics {

Wyświetl plik

@ -62,6 +62,16 @@ namespace pimoroni {
}
}
void PicoGraphics_PenRGB565::set_pixel_alpha(const Point &p, const uint8_t a) {
if(!bounds.contains(p)) return;
uint16_t *buf = (uint16_t *)frame_buffer;
RGB565 blended = RGB(buf[p.y * bounds.w + p.x]).blend(RGB(color), a).to_rgb565();
buf[p.y * bounds.w + p.x] = blended;
};
void PicoGraphics_PenRGB565::sprite(void* data, const Point &sprite, const Point &dest, const int scale, const int transparent) {
//int sprite_x = (sprite & 0x0f) << 3;
//int sprite_y = (sprite & 0xf0) >> 1;