2#ifdef USE_ONLINE_IMAGE_PNG_SUPPORT
8static const char *
const TAG =
"online_image.png";
11namespace online_image {
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);
47 ESP_LOGE(TAG,
"Failed to allocate memory for PNGLE engine!");
50 memset(pngle, 0, PNGLE_T_SIZE);
66 ESP_LOGE(TAG,
"PNG decoder engine not initialized!");
69 pngle_set_user_data(this->
pngle_,
this);
70 pngle_set_init_callback(this->
pngle_, init_callback);
71 pngle_set_draw_callback(this->
pngle_, draw_callback);
77 ESP_LOGE(TAG,
"PNG decoder engine not initialized!");
81 ESP_LOGD(TAG,
"Waiting for data");
84 auto fed = pngle_feed(this->
pngle_, buffer, size);
86 ESP_LOGE(TAG,
"Error decoding image: %s", pngle_error(this->
pngle_));
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.