ESPHome 2026.3.0
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 int HOT decode(uint8_t *buffer, size_t size) override;
27
28 bool is_finished() const override {
29 if (this->bits_per_pixel_ == 0) {
30 // header not yet received, so dimensions not yet determined
31 return false;
32 }
33 // BMP is finished when we've decoded all pixel data
34 return this->paint_index_ >= static_cast<size_t>(this->width_ * this->height_);
35 }
36
37 protected:
38 size_t current_index_{0};
39 size_t paint_index_{0};
42 uint16_t bits_per_pixel_{0};
46 std::unique_ptr<uint32_t[]> color_table_;
47 size_t width_bytes_{0};
48 size_t data_offset_{0};
49 uint8_t padding_bytes_{0};
50};
51
52} // namespace esphome::runtime_image
53
54#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:46
bool is_finished() const override
Definition bmp_decoder.h:28
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
size_t size
Definition helpers.h:929
static void uint32_t