ESPHome 2026.3.0
Loading...
Searching...
No Matches
image_decoder.h
Go to the documentation of this file.
1#pragma once
3
5
11
12class RuntimeImage;
13
18 public:
24 ImageDecoder(RuntimeImage *image) : image_(image) {}
25 virtual ~ImageDecoder() = default;
26
33 virtual int prepare(size_t expected_size) {
34 this->expected_size_ = expected_size;
35 return 0;
36 }
37
49 virtual int decode(uint8_t *buffer, size_t size) = 0;
50
59 bool set_size(int width, int height);
60
73 void draw(int x, int y, int w, int h, const Color &color);
74
81 virtual bool is_finished() const {
82 if (this->expected_size_ > 0) {
83 return this->decoded_bytes_ >= this->expected_size_;
84 }
85 // If size is unknown, derived classes should override this
86 return false;
87 }
88
89 protected:
91 size_t expected_size_ = 0; // Expected data size (0 if unknown)
92 size_t decoded_bytes_ = 0; // Bytes processed so far
93 double x_scale_ = 1.0;
94 double y_scale_ = 1.0;
95};
96
97} // namespace esphome::runtime_image
uint8_t h
Definition bl0906.h:2
Class to abstract decoding different image formats.
virtual bool is_finished() const
Check if the decoder has finished processing.
virtual int decode(uint8_t *buffer, size_t size)=0
Decode a part of the image.
void draw(int x, int y, int w, int h, const Color &color)
Fill a rectangle on the display_buffer using the defined color.
ImageDecoder(RuntimeImage *image)
Construct a new Image Decoder object.
bool set_size(int width, int height)
Request the image to be resized once the actual dimensions are known.
virtual int prepare(size_t expected_size)
Initialize the decoder.
A dynamic image that can be loaded and decoded at runtime.
size_t size
Definition helpers.h:929
uint16_t x
Definition tt21100.cpp:5
uint16_t y
Definition tt21100.cpp:6