Skip to content

Commit

Permalink
removed memory waste
Browse files Browse the repository at this point in the history
  • Loading branch information
lubeda committed Nov 28, 2024
1 parent 8c30193 commit 76ec608
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions components/ehmtxv2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
MAXICONS = 120
ICONWIDTH = 8
ICONHEIGHT = 8
ICONBUFFERSIZE = ICONWIDTH * ICONHEIGHT * 4
ICONBUFFERSIZE = ICONWIDTH * ICONHEIGHT * 2
SVG_ICONSTART = '<svg width="80px" height="80px" viewBox="0 0 80 80">'
SVG_FULL_SCREEN_START = '<svg width="320px" height="80px" viewBox="0 0 320 80">'
SVG_END = "</svg>"
Expand Down Expand Up @@ -446,11 +446,15 @@ def thumbnails(frames):
pos = 0
frameIndex = 0
html_string += f"<DIV ID={conf[CONF_ID]}>"
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])

Expand All @@ -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
Expand Down

0 comments on commit 76ec608

Please sign in to comment.