ESPHome 2026.11.0b6
Loading...
Searching...
No Matches
bmp_decoder.h
Go to the documentation of this file.
1#pragma once
2
4#ifdef USE_RUNTIME_IMAGE_BMP
5
6#include <algorithm>
7#include <memory>
8
9#include "image_decoder.h"
10#include "runtime_image.h"
11
12namespace esphome::runtime_image {
13
17class BmpDecoder : public ImageDecoder {
18 public:
25
26 void reset() override;
27 int HOT decode(uint8_t *buffer, size_t size) override;
28
30 bool knows_end() const override { return this->bits_per_pixel_ != 0; }
31 bool is_finished() const override {
32 return this->knows_end() && this->paint_index_ >= static_cast<size_t>(this->width_ * this->height_);
33 }
34
35 protected:
36 std::unique_ptr<uint32_t[]> color_table_;
37 size_t current_index_{0};
38 size_t paint_index_{0};
41 size_t width_bytes_{0};
42 size_t data_offset_{0};
46 uint32_t color_table_capacity_{0}; // Allocated entries in color_table_, kept across decodes
47 uint16_t bits_per_pixel_{0};
48 uint8_t padding_bytes_{0};
49};
50
51} // namespace esphome::runtime_image
52
53#endif // USE_RUNTIME_IMAGE_BMP
Image decoder specialization for BMP images.
Definition bmp_decoder.h:17
bool knows_end() const override
The header gives the pixel count, so the end is known once it has been parsed.
Definition bmp_decoder.h:30
std::unique_ptr< uint32_t[]> color_table_
Definition bmp_decoder.h:36
bool is_finished() const override
Definition bmp_decoder.h:31
BmpDecoder(RuntimeImage *image)
Construct a new BMP Decoder object.
Definition bmp_decoder.h:24
int HOT decode(uint8_t *buffer, size_t size) override
Class to abstract decoding different image formats.
A dynamic image that can be loaded and decoded at runtime.
uint32_t buffer
Definition gif.cpp:50
__int64 ssize_t
Definition httplib.h:178
uint16_t size
Definition helpers.cpp:34
static void uint32_t