ESPHome 2026.11.0b6
Loading...
Searching...
No Matches
esphome::runtime_image::QoiDecoder Class Reference

Image decoder specialization for QOI images. More...

#include <qoi_decoder.h>

Inheritance diagram for esphome::runtime_image::QoiDecoder:
esphome::runtime_image::ImageDecoder

Public Member Functions

 QoiDecoder (RuntimeImage *image)
 Construct a new QOI decoder object.
 
void reset () override
 
int HOT decode (uint8_t *buffer, size_t size) override
 
bool knows_end () const override
 The header gives the pixel count, so the end is known once it has been parsed.
 
bool is_finished () const override
 
- Public Member Functions inherited from esphome::runtime_image::ImageDecoder
 ImageDecoder (RuntimeImage *image, ImageFormat format)
 Construct a new Image Decoder object.
 
virtual ~ImageDecoder ()=default
 
ImageFormat get_format () const
 Get the image format handled by this decoder.
 
bool is_active () const
 Check if a decoding session is in progress (prepare() called, reset() not yet).
 
virtual int prepare (size_t expected_size)
 Initialize the decoder, starting a new decoding session.
 
virtual bool supports_source () const
 Whether this decoder can read a DecodeSource itself, a step at a time, instead of being fed data.
 
virtual int begin_source (DecodeSource *source)
 Start decoding from a source the decoder reads itself.
 
virtual int decode_step ()
 Decode a little more of an image started with begin_source(), keeping each call short.
 
bool set_size (int width, int height)
 Request the image to be resized once the actual dimensions are known.
 
void draw (int x, int y, int w, int h, const Color &color)
 Fill a rectangle on the display_buffer using the defined color.
 
size_t get_decoded_bytes () const
 Bytes of the image the decoder has used so far.
 
bool uses_direct_rgb565 () const
 The image is opaque RGB565, so draw() writes it straight into the buffer.
 

Protected Attributes

std::unique_ptr< Color[]> color_table_
 
size_t current_index_ {0}
 
size_t paint_index_ {0}
 
size_t width_ {0}
 
size_t height_ {0}
 
Color last_pixel_ {0, 0, 0, 255}
 
uint16_t bits_per_pixel_ {0}
 
- Protected Attributes inherited from esphome::runtime_image::ImageDecoder
int draw_width_ = 0
 
int draw_height_ = 0
 
FixedVector< uint16_t > x_boundaries_ {}
 
FixedVector< uint16_t > y_boundaries_ {}
 
RuntimeImage * image_
 
size_t expected_size_ = 0
 
size_t decoded_bytes_ = 0
 
const ImageFormat format_
 
bool active_ = false
 
bool size_valid_ = true
 
bool direct_rgb565_ = false
 

Additional Inherited Members

- Protected Member Functions inherited from esphome::runtime_image::ImageDecoder
bool resize_image_ (int width, int height)
 Resize the image for a width x height source, without preparing to draw. prepare_draw_() must follow.
 
void prepare_draw_ (int width, int height)
 Draw a source of width x height over the whole buffer from now on.
 
void draw_rgb565_ (int x, int y, int w, int h, uint16_t rgb565)
 Paint a block of source pixels in one color straight into the buffer. Only while uses_direct_rgb565().
 
uint8_t * image_buffer_ () const
 The image's pixel buffer, for decoders that write their output straight into it.
 
bool image_is_big_endian_ () const
 

Detailed Description

Image decoder specialization for QOI images.

Definition at line 16 of file qoi_decoder.h.

Constructor & Destructor Documentation

◆ QoiDecoder()

esphome::runtime_image::QoiDecoder::QoiDecoder ( RuntimeImage * image)
inline

Construct a new QOI decoder object.

Parameters
imageThe RuntimeImage to decode the stream into.

Definition at line 23 of file qoi_decoder.h.

Member Function Documentation

◆ decode()

int HOT esphome::runtime_image::QoiDecoder::decode ( uint8_t * buffer,
size_t size )
overridevirtual

QOI Header definition, for reference: char magic[4]; // magic bytes "qoif" uint32_t width; // image width in pixels (BE) uint32_t height; // image height in pixels (BE) uint8_t channels; // 3 = RGB, 4 = RGBA uint8_t colorspace; // 0 = sRGB with linear alpha, 1 = all channels linear

Implements esphome::runtime_image::ImageDecoder.

Definition at line 53 of file qoi_decoder.cpp.

◆ is_finished()

bool esphome::runtime_image::QoiDecoder::is_finished ( ) const
inlineoverridevirtual

Reimplemented from esphome::runtime_image::ImageDecoder.

Definition at line 30 of file qoi_decoder.h.

◆ knows_end()

bool esphome::runtime_image::QoiDecoder::knows_end ( ) const
inlineoverridevirtual

The header gives the pixel count, so the end is known once it has been parsed.

Reimplemented from esphome::runtime_image::ImageDecoder.

Definition at line 29 of file qoi_decoder.h.

◆ reset()

void esphome::runtime_image::QoiDecoder::reset ( )
overridevirtual

Reimplemented from esphome::runtime_image::ImageDecoder.

Definition at line 40 of file qoi_decoder.cpp.

Field Documentation

◆ bits_per_pixel_

uint16_t esphome::runtime_image::QoiDecoder::bits_per_pixel_ {0}
protected

Definition at line 41 of file qoi_decoder.h.

◆ color_table_

std::unique_ptr<Color[]> esphome::runtime_image::QoiDecoder::color_table_
protected

Definition at line 35 of file qoi_decoder.h.

◆ current_index_

size_t esphome::runtime_image::QoiDecoder::current_index_ {0}
protected

Definition at line 36 of file qoi_decoder.h.

◆ height_

size_t esphome::runtime_image::QoiDecoder::height_ {0}
protected

Definition at line 39 of file qoi_decoder.h.

◆ last_pixel_

Color esphome::runtime_image::QoiDecoder::last_pixel_ {0, 0, 0, 255}
protected

Definition at line 40 of file qoi_decoder.h.

◆ paint_index_

size_t esphome::runtime_image::QoiDecoder::paint_index_ {0}
protected

Definition at line 37 of file qoi_decoder.h.

◆ width_

size_t esphome::runtime_image::QoiDecoder::width_ {0}
protected

Definition at line 38 of file qoi_decoder.h.


The documentation for this class was generated from the following files: