2#ifdef USE_RUNTIME_IMAGE_PNG
16static constexpr size_t FEED_PIECE_SIZE = 64;
27 PngDecoder *decoder = (PngDecoder *) pngle_get_user_data(pngle);
28 decoder->set_size(w,
h);
43 PngDecoder *decoder = (PngDecoder *) pngle_get_user_data(pngle);
44 Color color(rgba[0], rgba[1], rgba[2], rgba[3]);
45 decoder->draw(
x,
y, w,
h, color);
50 decoder->increment_pixels_decoded(pixels);
51 if ((decoder->get_pixels_decoded() % 1024) < pixels) {
59 pngle_t *pngle = allocator.
allocate(1, PNGLE_T_SIZE);
61 ESP_LOGE(TAG,
"Failed to allocate memory for PNGLE engine!");
64 memset(pngle, 0, PNGLE_T_SIZE);
81 ESP_LOGE(TAG,
"PNG decoder engine not initialized!");
85 pngle_set_user_data(this->
pngle_,
this);
86 pngle_set_init_callback(this->
pngle_, init_callback);
87 pngle_set_draw_callback(this->
pngle_, draw_callback);
93 ESP_LOGE(TAG,
"PNG decoder engine not initialized!");
98 ESP_LOGD(TAG,
"Waiting for more data");
105 while (total <
size) {
106 const size_t piece = std::min(FEED_PIECE_SIZE,
size - total);
107 const int fed = pngle_feed(this->
pngle_, buffer + total, piece);
109 ESP_LOGE(TAG,
"Error decoding image: %s", pngle_error(this->
pngle_));
117 if (fed == 0 ||
millis() - start >= DECODE_TIME_LIMIT_MS)
void feed_wdt()
Feed the task watchdog.
An STL allocator that uses SPI or internal RAM.
void deallocate(T *p, size_t n)
Class to abstract decoding different image formats.
virtual int prepare(size_t expected_size)
Initialize the decoder, starting a new decoding session.
int HOT decode(uint8_t *buffer, size_t size) override
PngDecoder(RuntimeImage *image)
Construct a new PNG Decoder object.
int prepare(size_t expected_size) override
A dynamic image that can be loaded and decoded at runtime.
static void int int int w
@ DECODE_ERROR_INTERNAL_DECODER_ERROR
@ DECODE_ERROR_OUT_OF_MEMORY
uint32_t IRAM_ATTR HOT millis()
Application App
Global storage of Application pointer - only one Application can exist.
ESPHOME_LOG_TAG(TAG, "image_decoder.png")