ESPHome 2025.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 {
10namespace image {
11
18
24
25class Image : public display::BaseImage {
26 public:
27 Image(const uint8_t *data_start, int width, int height, ImageType type, Transparency transparency);
28 Color get_pixel(int x, int y, Color color_on = display::COLOR_ON, Color color_off = display::COLOR_OFF) const;
29 int get_width() const override;
30 int get_height() const override;
31 const uint8_t *get_data_start() const { return this->data_start_; }
32 ImageType get_type() const;
33
34 int get_bpp() const { return this->bpp_; }
35
38 size_t get_width_stride() const { return (this->width_ * this->get_bpp() + 7u) / 8u; }
39 void draw(int x, int y, display::Display *display, Color color_on, Color color_off) override;
40
41 bool has_transparency() const { return this->transparency_ != TRANSPARENCY_OPAQUE; }
42
43#ifdef USE_LVGL
44 lv_img_dsc_t *get_lv_img_dsc();
45#endif
46 protected:
47 bool get_binary_pixel_(int x, int y) const;
48 Color get_rgb_pixel_(int x, int y) const;
49 Color get_rgb565_pixel_(int x, int y) const;
50 Color get_grayscale_pixel_(int x, int y) const;
51
52 int width_;
55 const uint8_t *data_start_;
57 size_t bpp_{};
58 size_t stride_{};
59#ifdef USE_LVGL
60 lv_img_dsc_t dsc_{};
61#endif
62};
63
64} // namespace image
65} // namespace esphome
Color get_rgb565_pixel_(int x, int y) const
Definition image.cpp:192
const uint8_t * data_start_
Definition image.h:55
int get_bpp() const
Definition image.h:34
Color get_rgb_pixel_(int x, int y) const
Definition image.cpp:172
bool has_transparency() const
Definition image.h:41
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:38
Image(const uint8_t *data_start, int width, int height, ImageType type, Transparency transparency)
Definition image.cpp:230
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:54
int get_height() const override
Definition image.cpp:228
ImageType get_type() const
Definition image.cpp:229
bool get_binary_pixel_(int x, int y) const
Definition image.cpp:167
const uint8_t * get_data_start() const
Definition image.h:31
lv_img_dsc_t * get_lv_img_dsc()
Definition image.cpp:107
Transparency transparency_
Definition image.h:56
lv_img_dsc_t dsc_
Definition image.h:60
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:227
Color get_grayscale_pixel_(int x, int y) const
Definition image.cpp:213
uint8_t type
const Color COLOR_ON(255, 255, 255, 255)
Turn the pixel ON.
Definition display.h:193
const Color COLOR_OFF(0, 0, 0, 0)
Turn the pixel OFF.
Definition display.h:191
@ TRANSPARENCY_ALPHA_CHANNEL
Definition image.h:22
@ TRANSPARENCY_CHROMA_KEY
Definition image.h:21
@ TRANSPARENCY_OPAQUE
Definition image.h:20
@ IMAGE_TYPE_GRAYSCALE
Definition image.h:14
@ IMAGE_TYPE_BINARY
Definition image.h:13
@ IMAGE_TYPE_RGB565
Definition image.h:16
@ IMAGE_TYPE_RGB
Definition image.h:15
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7
uint16_t x
Definition tt21100.cpp:5
uint16_t y
Definition tt21100.cpp:6