mirror of
https://github.com/esphome/esphome.git
synced 2025-03-13 22:28:14 +00:00
fmt fixes
This commit is contained in:
parent
c5fcbb9404
commit
68b4c16fd4
@ -71,6 +71,7 @@ class JPEGFormat(Format):
|
||||
cg.add_define("USE_ONLINE_IMAGE_JPEG_SUPPORT")
|
||||
cg.add_library("JPEGDEC", None, "https://github.com/bitbank2/JPEGDEC#ca1e0f2")
|
||||
|
||||
|
||||
class WEBPFormat(Format):
|
||||
def __init__(self):
|
||||
super().__init__("WEBP")
|
||||
@ -79,6 +80,7 @@ class WEBPFormat(Format):
|
||||
cg.add_define("USE_ONLINE_IMAGE_WEBP_SUPPORT")
|
||||
cg.add_library("libwebp", None, "https://github.com/acvigue/libwebp#26b0c4b")
|
||||
|
||||
|
||||
class PNGFormat(Format):
|
||||
def __init__(self):
|
||||
super().__init__("PNG")
|
||||
@ -99,7 +101,9 @@ IMAGE_FORMATS = {
|
||||
}
|
||||
IMAGE_FORMATS.update({"JPG": IMAGE_FORMATS["JPEG"]})
|
||||
|
||||
OnlineImage = online_image_ns.class_("OnlineImage", cg.PollingComponent, Image_, Animation_)
|
||||
OnlineImage = online_image_ns.class_(
|
||||
"OnlineImage", cg.PollingComponent, Image_, Animation_
|
||||
)
|
||||
|
||||
# Actions
|
||||
SetUrlAction = online_image_ns.class_(
|
||||
|
@ -267,7 +267,8 @@ void OnlineImage::draw_pixel_(int x, int y, Color color, int frame) {
|
||||
ESP_LOGE(TAG, "Buffer not allocated!");
|
||||
return;
|
||||
}
|
||||
if (x < 0 || y < 0 || frame < 0 || x >= this->buffer_width_ || y >= this->buffer_height_ || frame >= this->animation_frame_count_) {
|
||||
if (x < 0 || y < 0 || frame < 0 || x >= this->buffer_width_ || y >= this->buffer_height_ ||
|
||||
frame >= this->animation_frame_count_) {
|
||||
ESP_LOGE(TAG, "Tried to paint a pixel (%d,%d,%d) outside the image!", x, y, frame);
|
||||
return;
|
||||
}
|
||||
|
@ -97,8 +97,12 @@ class OnlineImage : public PollingComponent,
|
||||
|
||||
RAMAllocator<uint8_t> allocator_{};
|
||||
|
||||
uint32_t get_buffer_size_() const { return get_buffer_size_(this->buffer_width_, this->buffer_height_, this->animation_frame_count_); }
|
||||
int get_buffer_size_(int width, int height, int frames) const { return frames * ((this->get_bpp() * width + 7u) / 8u * height); }
|
||||
uint32_t get_buffer_size_() const {
|
||||
return get_buffer_size_(this->buffer_width_, this->buffer_height_, this->animation_frame_count_);
|
||||
}
|
||||
int get_buffer_size_(int width, int height, int frames) const {
|
||||
return frames * ((this->get_bpp() * width + 7u) / 8u * height);
|
||||
}
|
||||
|
||||
int get_position_(int x, int y, int frame = 0) const {
|
||||
int frame_offset = this->buffer_frame_size_ * frame;
|
||||
|
@ -81,10 +81,11 @@ int HOT WebpDecoder::decode(uint8_t *buffer, size_t size) {
|
||||
return DECODE_ERROR_UNSUPPORTED_FORMAT;
|
||||
}
|
||||
|
||||
ESP_LOGD(TAG, "WebPAnimDecode size: (%dx%d), loops: %d, frames: %d, bgcolor: #%X", animation_.canvas_width, animation_.canvas_height, animation_.loop_count, animation_.frame_count, animation_.bgcolor);
|
||||
ESP_LOGD(TAG, "WebPAnimDecode size: (%dx%d), loops: %d, frames: %d, bgcolor: #%X", animation_.canvas_width,
|
||||
animation_.canvas_height, animation_.loop_count, animation_.frame_count, animation_.bgcolor);
|
||||
|
||||
if (!this->set_size(animation_.canvas_width, animation_.canvas_height, animation_.frame_count)) {
|
||||
ESP_LOGE(TAG,"could not allocate enough memory");
|
||||
ESP_LOGE(TAG, "could not allocate enough memory");
|
||||
WebPAnimDecoderDelete(this->decoder_);
|
||||
this->decoder_ = NULL;
|
||||
return DECODE_ERROR_OUT_OF_MEMORY;
|
||||
@ -102,7 +103,7 @@ int HOT WebpDecoder::decode(uint8_t *buffer, size_t size) {
|
||||
uint8_t *pix;
|
||||
int timestamp;
|
||||
if (!WebPAnimDecoderGetNext(this->decoder_, &pix, ×tamp)) {
|
||||
ESP_LOGE(TAG,"error parsing webp frame %u/%u", frame, animation_.frame_count);
|
||||
ESP_LOGE(TAG, "error parsing webp frame %u/%u", frame, animation_.frame_count);
|
||||
WebPAnimDecoderDelete(this->decoder_);
|
||||
this->decoder_ = NULL;
|
||||
return DECODE_ERROR_UNSUPPORTED_FORMAT;
|
||||
|
Loading…
x
Reference in New Issue
Block a user