3#ifdef USE_RUNTIME_IMAGE_BMP
49 ESP_LOGE(TAG,
"Not a BMP file");
84 ESP_LOGE(TAG,
"Invalid image dimensions: (%zdx%zd)", this->
width_, this->
height_);
106 size_t offset = 14 + header_size;
130 ESP_LOGE(TAG,
"Unsupported bits per pixel: %d", this->
bits_per_pixel_);
147 size_t width =
static_cast<size_t>(this->
width_);
148 while (index <
size) {
151 size_t remaining_in_row = width -
x;
152 uint8_t pixels_in_byte = std::min<size_t>(remaining_in_row, 8);
153 bool end_of_row = remaining_in_row <= 8;
155 if (index + needed >
size) {
159 uint8_t current_byte =
buffer[index];
160 for (uint8_t i = 0; i < pixels_in_byte; i++) {
162 this->
draw(x + i,
y, 1, 1, c);
176 size_t width =
static_cast<size_t>(this->
width_);
177 size_t last_col = width - 1;
178 while (index <
size) {
182 if (index + needed >
size) {
187 uint8_t color_index =
buffer[index];
189 ESP_LOGE(TAG,
"Invalid color index: %u", color_index);
194 uint8_t b = rgb & 0xff;
195 uint8_t g = (rgb >> 8) & 0xff;
196 uint8_t r = (rgb >> 16) & 0xff;
209 size_t width =
static_cast<size_t>(this->
width_);
210 size_t last_col = width - 1;
211 while (index <
size) {
215 if (index + needed >
size) {
219 uint8_t b =
buffer[index];
220 uint8_t g =
buffer[index + 1];
221 uint8_t r =
buffer[index + 2];
234 ESP_LOGE(TAG,
"Unsupported bits per pixel: %d", this->
bits_per_pixel_);
uint32_t image_data_size_
uint32_t color_table_entries_
std::unique_ptr< uint32_t[]> color_table_
uint32_t compression_method_
uint32_t color_table_capacity_
int HOT decode(uint8_t *buffer, size_t size) override
virtual void reset()
Reset the decoder state, ending any decoding session.
void draw(int x, int y, int w, int h, const Color &color)
Fill a rectangle on the display_buffer using the defined color.
bool set_size(int width, int height)
Request the image to be resized once the actual dimensions are known.
constexpr Color COLOR_ON(255, 255, 255, 255)
Turn the pixel ON.
constexpr Color COLOR_OFF(0, 0, 0, 0)
Turn the pixel OFF.
@ DECODE_ERROR_OUT_OF_MEMORY
@ DECODE_ERROR_UNSUPPORTED_FORMAT
@ DECODE_ERROR_INVALID_TYPE
ESPHOME_LOG_TAG(TAG, "image_decoder.bmp")
constexpr uint32_t encode_uint32(uint8_t byte1, uint8_t byte2, uint8_t byte3, uint8_t byte4)
Encode a 32-bit value given four bytes in most to least significant byte order.
constexpr uint16_t encode_uint16(uint8_t msb, uint8_t lsb)
Encode a 16-bit value given the most and least significant byte.