From 76ec6081df785717f31cc72d2dc2a683cd4d8fe8 Mon Sep 17 00:00:00 2001 From: lubeda Date: Thu, 28 Nov 2024 12:03:13 +0100 Subject: [PATCH] removed memory waste --- components/ehmtxv2/__init__.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/components/ehmtxv2/__init__.py b/components/ehmtxv2/__init__.py index bdb561e..846d8d4 100644 --- a/components/ehmtxv2/__init__.py +++ b/components/ehmtxv2/__init__.py @@ -25,7 +25,7 @@ MAXICONS = 120 ICONWIDTH = 8 ICONHEIGHT = 8 -ICONBUFFERSIZE = ICONWIDTH * ICONHEIGHT * 4 +ICONBUFFERSIZE = ICONWIDTH * ICONHEIGHT * 2 SVG_ICONSTART = '' SVG_FULL_SCREEN_START = '' SVG_END = "" @@ -446,11 +446,15 @@ def thumbnails(frames): pos = 0 frameIndex = 0 html_string += f"
" - data = [0 for _ in range(ICONBUFFERSIZE * 2 * frames)] + data = [0 for _ in range(ICONBUFFERSIZE * frames)] + if image.has_transparency_data: + logging.warning(f" icon {conf[CONF_ID]} has transparency!") + for frameIndex in range(frames): image.seek(frameIndex) - frame = image.convert("RGBA") + frame = image.convert("RGB") + if CONF_RESIZE in conf: frame = frame.resize([width, height]) @@ -472,8 +476,7 @@ def thumbnails(frames): y = i//width i +=1 rgb = (R << 11) | (G << 5) | B - if pix[3] < 64: - rgb = 0 + html_string += rgb565_svg(x,y,R,G,B) data[pos] = rgb >> 8 pos += 1