Add transparency support to all image types (#4600)

This commit is contained in:
guillempages
2023-05-21 22:03:21 +02:00
committed by GitHub
parent c61a3bf431
commit 8a518f0def
8 changed files with 359 additions and 110 deletions
+8 -2
View File
@@ -82,8 +82,8 @@ enum ImageType {
IMAGE_TYPE_BINARY = 0,
IMAGE_TYPE_GRAYSCALE = 1,
IMAGE_TYPE_RGB24 = 2,
IMAGE_TYPE_TRANSPARENT_BINARY = 3,
IMAGE_TYPE_RGB565 = 4,
IMAGE_TYPE_RGB565 = 3,
IMAGE_TYPE_RGBA = 4,
};
enum DisplayType {
@@ -540,6 +540,7 @@ class Image {
Image(const uint8_t *data_start, int width, int height, ImageType type);
virtual bool get_pixel(int x, int y) const;
virtual Color get_color_pixel(int x, int y) const;
virtual Color get_rgba_pixel(int x, int y) const;
virtual Color get_rgb565_pixel(int x, int y) const;
virtual Color get_grayscale_pixel(int x, int y) const;
int get_width() const;
@@ -548,11 +549,15 @@ class Image {
virtual int get_current_frame() const;
void set_transparency(bool transparent) { transparent_ = transparent; }
bool has_transparency() const { return transparent_; }
protected:
int width_;
int height_;
ImageType type_;
const uint8_t *data_start_;
bool transparent_;
};
class Animation : public Image {
@@ -560,6 +565,7 @@ class Animation : public Image {
Animation(const uint8_t *data_start, int width, int height, uint32_t animation_frame_count, ImageType type);
bool get_pixel(int x, int y) const override;
Color get_color_pixel(int x, int y) const override;
Color get_rgba_pixel(int x, int y) const override;
Color get_rgb565_pixel(int x, int y) const override;
Color get_grayscale_pixel(int x, int y) const override;