ESPHome 2026.9.0-dev
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
29 bool is_finished() const override {
30 if (this->bits_per_pixel_ == 0) {
31 // header not yet received, so dimensions not yet determined
32 return false;
33 }
34 // BMP is finished when we've decoded all pixel data
35 return this->paint_index_ >= static_cast<size_t>(this->width_ * this->height_);
36 }
37
38 protected:
39 std::unique_ptr<uint32_t[]> color_table_;
40 size_t current_index_{0};
41 size_t paint_index_{0};
44 size_t width_bytes_{0};
45 size_t data_offset_{0};
49 uint32_t color_table_capacity_{0}; // Allocated entries in color_table_, kept across decodes
50 uint16_t bits_per_pixel_{0};
51 uint8_t padding_bytes_{0};
52};
53
54} // namespace esphome::runtime_image
55
56#endif // USE_RUNTIME_IMAGE_BMP
Image decoder specialization for BMP images.
Definition bmp_decoder.h:17
std::unique_ptr< uint32_t[]> color_table_
Definition bmp_decoder.h:39
bool is_finished() const override
Definition bmp_decoder.h:29
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.
__int64 ssize_t
Definition httplib.h:178
uint16_t size
Definition helpers.cpp:25
static void uint32_t