Class to abstract decoding different image formats.
More...
#include <image_decoder.h>
|
| | 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 void | reset () |
| | Reset the decoder state, ending any decoding session.
|
| |
| virtual int | prepare (size_t expected_size) |
| | Initialize the decoder, starting a new decoding session.
|
| |
| virtual int | decode (uint8_t *buffer, size_t size)=0 |
| | Decode a part of the image.
|
| |
| 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.
|
| |
| virtual bool | is_finished () const |
| | Check if the decoder has finished processing.
|
| |
Class to abstract decoding different image formats.
Definition at line 34 of file image_decoder.h.
◆ ImageDecoder()
Construct a new Image Decoder object.
- Parameters
-
| image | The RuntimeImage to decode the stream into. |
| format | The image format this decoder handles. |
Definition at line 42 of file image_decoder.h.
◆ ~ImageDecoder()
| virtual esphome::runtime_image::ImageDecoder::~ImageDecoder |
( |
| ) |
|
|
virtualdefault |
◆ decode()
| virtual int esphome::runtime_image::ImageDecoder::decode |
( |
uint8_t * | buffer, |
|
|
size_t | size ) |
|
pure virtual |
Decode a part of the image.
It will try reading from the buffer. There is no guarantee that the whole available buffer will be read/decoded; the method will return the amount of bytes actually decoded, so that the unread content can be moved to the beginning.
- Parameters
-
| buffer | The buffer to read from. |
| size | The maximum amount of bytes that can be read from the buffer. |
- Returns
- int The amount of bytes read. It can be 0 if the buffer does not have enough content to meaningfully decode anything, or negative in case of a decoding error.
Implemented in esphome::runtime_image::BmpDecoder, esphome::runtime_image::JpegDecoder, esphome::runtime_image::PngDecoder, and esphome::runtime_image::QoiDecoder.
◆ draw()
| void esphome::runtime_image::ImageDecoder::draw |
( |
int | x, |
|
|
int | y, |
|
|
int | w, |
|
|
int | h, |
|
|
const Color & | color ) |
Fill a rectangle on the display_buffer using the defined color.
Will check the given coordinates for out-of-bounds, and clip the rectangle accordingly. In case of binary displays, the color will be converted to binary as well. Called by the callback functions, to be able to access the parent Image class.
- Parameters
-
| x | The left-most coordinate of the rectangle. |
| y | The top-most coordinate of the rectangle. |
| w | The width of the rectangle. |
| h | The height of the rectangle. |
| color | The fill color |
Definition at line 19 of file image_decoder.cpp.
◆ get_format()
| ImageFormat esphome::runtime_image::ImageDecoder::get_format |
( |
| ) |
const |
|
inline |
Get the image format handled by this decoder.
Definition at line 46 of file image_decoder.h.
◆ is_active()
| bool esphome::runtime_image::ImageDecoder::is_active |
( |
| ) |
const |
|
inline |
◆ is_finished()
| virtual bool esphome::runtime_image::ImageDecoder::is_finished |
( |
| ) |
const |
|
inlinevirtual |
◆ prepare()
| virtual int esphome::runtime_image::ImageDecoder::prepare |
( |
size_t | expected_size | ) |
|
|
inlinevirtual |
Initialize the decoder, starting a new decoding session.
- Parameters
-
| expected_size | Hint about the expected data size (0 if unknown). |
- Returns
- int Returns 0 on success, a {
- See also
- DecodeError} value in case of an error.
Reimplemented in esphome::runtime_image::PngDecoder.
Definition at line 71 of file image_decoder.h.
◆ reset()
| virtual void esphome::runtime_image::ImageDecoder::reset |
( |
| ) |
|
|
inlinevirtual |
◆ set_size()
| bool esphome::runtime_image::ImageDecoder::set_size |
( |
int | width, |
|
|
int | height ) |
Request the image to be resized once the actual dimensions are known.
Called by the callback functions, to be able to access the parent Image class.
- Parameters
-
| width | The image's width. |
| height | The image's height. |
- Returns
- true if the image was resized, false otherwise.
Definition at line 11 of file image_decoder.cpp.
◆ active_
| bool esphome::runtime_image::ImageDecoder::active_ = false |
|
protected |
◆ decoded_bytes_
| size_t esphome::runtime_image::ImageDecoder::decoded_bytes_ = 0 |
|
protected |
◆ expected_size_
| size_t esphome::runtime_image::ImageDecoder::expected_size_ = 0 |
|
protected |
◆ format_
| const ImageFormat esphome::runtime_image::ImageDecoder::format_ |
|
protected |
◆ image_
◆ size_valid_
| bool esphome::runtime_image::ImageDecoder::size_valid_ = true |
|
protected |
◆ x_scale_
| double esphome::runtime_image::ImageDecoder::x_scale_ = 1.0 |
|
protected |
◆ y_scale_
| double esphome::runtime_image::ImageDecoder::y_scale_ = 1.0 |
|
protected |
The documentation for this class was generated from the following files: