2#ifdef USE_ONLINE_IMAGE_PNG_SUPPORT
9static const char *
const TAG =
"online_image.png";
12namespace online_image {
22static void init_callback(pngle_t *pngle, uint32_t w, uint32_t
h) {
23 PngDecoder *decoder = (PngDecoder *) pngle_get_user_data(pngle);
24 decoder->set_size(w,
h);
38static void draw_callback(pngle_t *pngle, uint32_t
x, uint32_t
y, uint32_t w, uint32_t
h,
const uint8_t rgba[4]) {
39 PngDecoder *decoder = (PngDecoder *) pngle_get_user_data(pngle);
40 Color color(rgba[0], rgba[1], rgba[2], rgba[3]);
41 decoder->draw(
x,
y, w,
h, color);
46 decoder->increment_pixels_decoded(pixels);
47 if ((decoder->get_pixels_decoded() % 1024) < pixels) {
56 ESP_LOGE(TAG,
"Failed to allocate memory for PNGLE engine!");
59 memset(pngle, 0, PNGLE_T_SIZE);
75 ESP_LOGE(TAG,
"PNG decoder engine not initialized!");
78 pngle_set_user_data(this->
pngle_,
this);
79 pngle_set_init_callback(this->
pngle_, init_callback);
80 pngle_set_draw_callback(this->
pngle_, draw_callback);
86 ESP_LOGE(TAG,
"PNG decoder engine not initialized!");
90 ESP_LOGD(TAG,
"Waiting for 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 download_size)
Initialize the decoder.
Download an image from a given URL, and decode it using the specified decoder.
PngDecoder(OnlineImage *image)
Construct a new PNG Decoder object.
int HOT decode(uint8_t *buffer, size_t size) override
int prepare(size_t download_size) override
RAMAllocator< pngle_t > allocator_
@ DECODE_ERROR_OUT_OF_MEMORY
Providing packet encoding functions for exchanging data with a remote host.
Application App
Global storage of Application pointer - only one Application can exist.