ESPHome 2026.9.0-dev
Loading...
Searching...
No Matches
qoi_decoder.h
Go to the documentation of this file.
1#pragma once
2
4#ifdef USE_RUNTIME_IMAGE_QOI
5
6#include <memory>
7
8#include "image_decoder.h"
9#include "runtime_image.h"
10
11namespace esphome::runtime_image {
12
16class QoiDecoder : public ImageDecoder {
17 public:
24
25 void reset() override;
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 // QOI 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 std::unique_ptr<Color[]> color_table_;
39 size_t current_index_{0};
40 size_t paint_index_{0};
41 size_t width_{0};
42 size_t height_{0};
43 Color last_pixel_{0, 0, 0, 255}; // QOI spec defines initial previous pixel as opaque black
44 uint16_t bits_per_pixel_{0};
45};
46
47} // namespace esphome::runtime_image
48
49#endif // USE_RUNTIME_IMAGE_QOI
Class to abstract decoding different image formats.
Image decoder specialization for QOI images.
Definition qoi_decoder.h:16
int HOT decode(uint8_t *buffer, size_t size) override
bool is_finished() const override
Definition qoi_decoder.h:28
QoiDecoder(RuntimeImage *image)
Construct a new QOI decoder object.
Definition qoi_decoder.h:23
std::unique_ptr< Color[]> color_table_
Definition qoi_decoder.h:38
A dynamic image that can be loaded and decoded at runtime.
uint16_t size
Definition helpers.cpp:25