ESPHome 2026.11.0b6
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
29 bool knows_end() const override { return this->bits_per_pixel_ != 0; }
30 bool is_finished() const override {
31 return this->knows_end() && this->paint_index_ >= static_cast<size_t>(this->width_ * this->height_);
32 }
33
34 protected:
35 std::unique_ptr<Color[]> color_table_;
36 size_t current_index_{0};
37 size_t paint_index_{0};
38 size_t width_{0};
39 size_t height_{0};
40 Color last_pixel_{0, 0, 0, 255}; // QOI spec defines initial previous pixel as opaque black
41 uint16_t bits_per_pixel_{0};
42};
43
44} // namespace esphome::runtime_image
45
46#endif // USE_RUNTIME_IMAGE_QOI
Class to abstract decoding different image formats.
Image decoder specialization for QOI images.
Definition qoi_decoder.h:16
bool knows_end() const override
The header gives the pixel count, so the end is known once it has been parsed.
Definition qoi_decoder.h:29
int HOT decode(uint8_t *buffer, size_t size) override
bool is_finished() const override
Definition qoi_decoder.h:30
QoiDecoder(RuntimeImage *image)
Construct a new QOI decoder object.
Definition qoi_decoder.h:23
std::unique_ptr< Color[]> color_table_
Definition qoi_decoder.h:35
A dynamic image that can be loaded and decoded at runtime.
uint32_t buffer
Definition gif.cpp:50
uint16_t size
Definition helpers.cpp:34