17 return "Invalid type";
19 return "Unsupported format";
21 return "Out of memory";
23 return "Internal decoder error";
25 return "Unknown error";
71 virtual int prepare(
size_t expected_size) {
99 bool set_size(
int width,
int height);
113 void draw(
int x,
int y,
int w,
int h,
const Color &color);
Class to abstract decoding different image formats.
virtual void reset()
Reset the decoder state, ending any decoding session.
ImageDecoder(RuntimeImage *image, ImageFormat format)
Construct a new Image Decoder object.
const ImageFormat format_
bool is_active() const
Check if a decoding session is in progress (prepare() called, reset() not yet).
virtual bool is_finished() const
Check if the decoder has finished processing.
virtual ~ImageDecoder()=default
virtual int decode(uint8_t *buffer, size_t size)=0
Decode a part of the image.
void draw(int x, int y, int w, int h, const Color &color)
Fill a rectangle on the display_buffer using the defined color.
ImageFormat get_format() const
Get the image format handled by this decoder.
bool set_size(int width, int height)
Request the image to be resized once the actual dimensions are known.
virtual int prepare(size_t expected_size)
Initialize the decoder, starting a new decoding session.
A dynamic image that can be loaded and decoded at runtime.
@ DECODE_ERROR_INTERNAL_DECODER_ERROR
@ DECODE_ERROR_OUT_OF_MEMORY
@ DECODE_ERROR_UNSUPPORTED_FORMAT
@ DECODE_ERROR_INVALID_TYPE
ImageFormat
Image format types that can be decoded dynamically.
constexpr const char * decode_error_to_string(int error)