1
0
mirror of https://github.com/esphome/esphome.git synced 2025-10-29 14:13:51 +00:00

[online_image] Improve error handling (#8212)

This commit is contained in:
guillempages
2025-02-11 12:12:13 +01:00
committed by GitHub
parent 8b7aa4c110
commit c9e7562aff
7 changed files with 35 additions and 13 deletions

View File

@@ -40,11 +40,16 @@ static void draw_callback(pngle_t *pngle, uint32_t x, uint32_t y, uint32_t w, ui
decoder->draw(x, y, w, h, color);
}
void PngDecoder::prepare(size_t download_size) {
int PngDecoder::prepare(size_t download_size) {
ImageDecoder::prepare(download_size);
if (!this->pngle_) {
ESP_LOGE(TAG, "PNG decoder engine not initialized!");
return DECODE_ERROR_OUT_OF_MEMORY;
}
pngle_set_user_data(this->pngle_, this);
pngle_set_init_callback(this->pngle_, init_callback);
pngle_set_draw_callback(this->pngle_, draw_callback);
return 0;
}
int HOT PngDecoder::decode(uint8_t *buffer, size_t size) {