35 image::Image *placeholder =
nullptr,
bool is_big_endian =
false,
int fixed_width = 0,
36 int fixed_height = 0);
54 int resize(
int width,
int height);
Input that a decoder reads itself as it goes, so the whole image never has to be in memory at once.
Class to abstract decoding different image formats.
A dynamic image that can be loaded and decoded at runtime.
int decode_step()
Decode a little more from the source; see ImageDecoder::decode_step().
bool is_loaded() const
Check if an image is currently loaded.
static void lvgl_widget_deleted(lv_event_t *event)
void set_double_buffer(bool double_buffer)
Set whether to decode into a second buffer, keeping the image on show until the new one is complete.
bool begin_decode(size_t expected_size=0, ImageFormat format=AUTO)
Begin decoding an image.
bool is_decoding() const
Check if decoding is currently in progress.
void draw(int x, int y, display::Display *display, Color color_on, Color color_off) override
size_t get_buffer_size(int width, int height) const
Get the buffer size in bytes needed for a picture of the given dimensions.
int buffer_width_
Actual width of the current image.
int begin_source(DecodeSource *source)
Decode from a source the decoder reads itself, in place of feed_data().
bool end_decode()
Complete the decoding process.
int get_buffer_height() const
void set_progressive_display(bool progressive)
Set whether to allow progressive display during decode.
int get_position_(int x, int y) const
Get the position in the buffer for a pixel.
const int fixed_height_
Fixed height requested on configuration, or 0 if not specified.
void release_buffer_()
Release only the image buffer without resetting the decoder.
void abort_decode()
End a decode that will not be finished.
int resize(int width, int height)
Resize the image buffer to the requested dimensions.
int feed_data(uint8_t *data, size_t len)
Feed data to the decoder.
const int fixed_width_
Fixed width requested on configuration, or 0 if not specified.
bool is_decode_finished() const
Check if the decoder has finished processing all data.
void release()
Release the image buffer and free its memory, ending any decode session.
image::Image * placeholder_
Placeholder image to show when the runtime image is not available.
RuntimeImage(ImageFormat format, image::ImageType type, image::Transparency transparency, image::Image *placeholder=nullptr, bool is_big_endian=false, int fixed_width=0, int fixed_height=0)
Construct a new RuntimeImage object.
bool decoder_knows_end() const
True while decoding and the decoder can tell a complete image from a cut-off one.
ImageFormat get_format() const
Get the image format.
bool is_double_buffered_() const
const ImageFormat format_
The image format this RuntimeImage is configured to decode.
int get_buffer_width() const
size_t resize_buffer_(int width, int height)
Resize the image buffer to the requested dimensions.
std::unique_ptr< ImageDecoder > decoder_
bool progressive_display_
lv_image_dsc_t * get_lv_image_dsc() override
Until an image is loaded, the placeholder's descriptor if there is one.
std::vector< lv_obj_t * > lvgl_widgets_
Widgets given this image. One moved to another image is dropped at the next refresh.
void draw_pixel(int x, int y, const Color &color)
std::unique_ptr< ImageDecoder > create_decoder_(ImageFormat format)
Create decoder instance for the requested format.
int buffer_height_
Actual height of the current image.
uint8_t * front_buffer_
With double buffering, the buffer on show, width_ by height_. buffer_ is then the one decoded into.
bool decoder_supports_source() const
Whether the active decoder can read a DecodeSource itself (see begin_source()).
bool set_external_buffer(uint8_t *buffer, int width, int height)
Decode into a buffer the caller owns, instead of one allocated here.
void refresh_lvgl_()
Bring the LVGL descriptor up to date after the image shown changed, and give it again to the widgets ...
void map_chroma_key(Color &color)
void add_lvgl_widget(lv_obj_t *obj) override
bool external_buffer_
Whether buffer_ belongs to the caller, so it must not be freed or resized here.
ImageFormat
Image format types that can be decoded dynamically.
@ AUTO
Format is supplied per decode, e.g.