2#ifdef USE_RUNTIME_IMAGE_PNG
9static const char *
const TAG =
"image_decoder.png";
21static void init_callback(pngle_t *pngle, uint32_t w, uint32_t
h) {
22 PngDecoder *decoder = (PngDecoder *) pngle_get_user_data(pngle);
23 decoder->set_size(w,
h);
37static void draw_callback(pngle_t *pngle, uint32_t
x, uint32_t
y, uint32_t w, uint32_t
h,
const uint8_t rgba[4]) {
38 PngDecoder *decoder = (PngDecoder *) pngle_get_user_data(pngle);
39 Color color(rgba[0], rgba[1], rgba[2], rgba[3]);
40 decoder->draw(
x,
y, w,
h, color);
45 decoder->increment_pixels_decoded(pixels);
46 if ((decoder->get_pixels_decoded() % 1024) < pixels) {
55 ESP_LOGE(TAG,
"Failed to allocate memory for PNGLE engine!");
58 memset(pngle, 0, PNGLE_T_SIZE);
74 ESP_LOGE(TAG,
"PNG decoder engine not initialized!");
77 pngle_set_user_data(this->
pngle_,
this);
78 pngle_set_init_callback(this->
pngle_, init_callback);
79 pngle_set_draw_callback(this->
pngle_, draw_callback);
85 ESP_LOGE(TAG,
"PNG decoder engine not initialized!");
90 ESP_LOGD(TAG,
"Waiting for more data");
93 auto fed = pngle_feed(this->
pngle_, buffer,
size);
95 ESP_LOGE(TAG,
"Error decoding image: %s", pngle_error(this->
pngle_));
void feed_wdt(uint32_t time=0)
void deallocate(T *p, size_t n)
Class to abstract decoding different image formats.
virtual int prepare(size_t expected_size)
Initialize the decoder.
int HOT decode(uint8_t *buffer, size_t size) override
PngDecoder(RuntimeImage *image)
Construct a new PNG Decoder object.
RAMAllocator< pngle_t > allocator_
int prepare(size_t expected_size) override
A dynamic image that can be loaded and decoded at runtime.
@ DECODE_ERROR_OUT_OF_MEMORY
Application App
Global storage of Application pointer - only one Application can exist.