ESPHome 2026.5.0
Loading...
Searching...
No Matches
image.h
Go to the documentation of this file.
1#pragma once
4
5#ifdef USE_LVGL
7#endif // USE_LVGL
8
9namespace esphome::image {
10
17
23
24class Image : public display::BaseImage {
25 public:
26 Image(const uint8_t *data_start, int width, int height, ImageType type, Transparency transparency);
27 Color get_pixel(int x, int y, Color color_on = display::COLOR_ON, Color color_off = display::COLOR_OFF) const;
28 int get_width() const override;
29 int get_height() const override;
30 const uint8_t *get_data_start() const { return this->data_start_; }
31 ImageType get_type() const;
32
33 int get_bpp() const { return this->bpp_; }
34
37 size_t get_width_stride() const { return (this->width_ * this->get_bpp() + 7u) / 8u; }
38 void draw(int x, int y, display::Display *display, Color color_on, Color color_off) override;
39
40 bool has_transparency() const { return this->transparency_ != TRANSPARENCY_OPAQUE; }
41
42#ifdef USE_LVGL
43 lv_image_dsc_t *get_lv_image_dsc();
44#endif
45 protected:
46 bool get_binary_pixel_(int x, int y) const;
47 Color get_rgb_pixel_(int x, int y) const;
48 Color get_rgb565_pixel_(int x, int y) const;
49 Color get_grayscale_pixel_(int x, int y) const;
50
51 int width_;
54 const uint8_t *data_start_;
56 size_t bpp_{};
57 size_t stride_{};
58#ifdef USE_LVGL
59 lv_img_dsc_t dsc_{};
60#endif
61};
62
63} // namespace esphome::image
Color get_rgb565_pixel_(int x, int y) const
Definition image.cpp:189
const uint8_t * data_start_
Definition image.h:54
int get_bpp() const
Definition image.h:33
Color get_rgb_pixel_(int x, int y) const
Definition image.cpp:169
bool has_transparency() const
Definition image.h:40
size_t get_width_stride() const
Return the stride of the image in bytes, that is, the distance in bytes between two consecutive rows ...
Definition image.h:37
Image(const uint8_t *data_start, int width, int height, ImageType type, Transparency transparency)
Definition image.cpp:227
Color get_pixel(int x, int y, Color color_on=display::COLOR_ON, Color color_off=display::COLOR_OFF) const
Definition image.cpp:88
ImageType type_
Definition image.h:53
int get_height() const override
Definition image.cpp:225
ImageType get_type() const
Definition image.cpp:226
bool get_binary_pixel_(int x, int y) const
Definition image.cpp:164
const uint8_t * get_data_start() const
Definition image.h:30
Transparency transparency_
Definition image.h:55
lv_img_dsc_t dsc_
Definition image.h:59
lv_image_dsc_t * get_lv_image_dsc()
Definition image.cpp:107
void draw(int x, int y, display::Display *display, Color color_on, Color color_off) override
Definition image.cpp:8
int get_width() const override
Definition image.cpp:224
Color get_grayscale_pixel_(int x, int y) const
Definition image.cpp:210
uint16_t type
constexpr Color COLOR_ON(255, 255, 255, 255)
Turn the pixel ON.
constexpr Color COLOR_OFF(0, 0, 0, 0)
Turn the pixel OFF.
@ TRANSPARENCY_ALPHA_CHANNEL
Definition image.h:21
@ TRANSPARENCY_CHROMA_KEY
Definition image.h:20
@ TRANSPARENCY_OPAQUE
Definition image.h:19
@ IMAGE_TYPE_GRAYSCALE
Definition image.h:13
@ IMAGE_TYPE_BINARY
Definition image.h:12
@ IMAGE_TYPE_RGB565
Definition image.h:15
@ IMAGE_TYPE_RGB
Definition image.h:14
uint16_t x
Definition tt21100.cpp:5
uint16_t y
Definition tt21100.cpp:6