Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions components/ehmtxv2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from esphome.const import CONF_BLUE, CONF_GREEN, CONF_RED, CONF_RESIZE, CONF_FILE, CONF_ID, CONF_BRIGHTNESS, CONF_RAW_DATA_ID, CONF_TIME, CONF_TRIGGER_ID
from esphome.core import CORE, HexInt
from esphome.cpp_generator import RawExpression
from esphome.components.image import CONF_ALPHA_CHANNEL, IMAGE_TYPE
from esphome.components.image import CONF_CHROMA_KEY, IMAGE_TYPE

from urllib.parse import urlparse

Expand Down Expand Up @@ -484,7 +484,15 @@ def openImageFile(path):
yaml_string += F"\"{conf[CONF_ID]}\","

dither = Image.Dither.NONE
transparency = CONF_ALPHA_CHANNEL
# Use CHROMA_KEY instead of ALPHA_CHANNEL: on ESPHome 2026.4.0 the
# appended-alpha layout is incompatible with Animation frame indexing
# (Animation::update_data_start_ advances by w*h*2 per frame, ignoring
# the alpha block). Chroma-key stores the transparent-pixel marker
# inline (0x0020), so each frame is exactly w*h*2 bytes and the C++
# Animation class can index into it correctly on every ESPHome
# version. 8x8 pixel-art icons use binary transparency anyway —
# fixes issue #331.
transparency = CONF_CHROMA_KEY
invert_alpha = False

total_rows = height * frames
Expand All @@ -495,6 +503,12 @@ def openImageFile(path):
dither,
invert_alpha,
)
# ESPHome 2026.4.0 flipped the default RGB565 byte order to little-
# endian, but the C++ Image::get_rgb565_pixel_ decoder still reads
# big-endian. set_big_endian exists on every ESPHome release that
# supports EHMTXv2; no-op on <2026.4.0 where BE was already default.
if hasattr(encoder, "set_big_endian"):
encoder.set_big_endian(True)
for frame_index in range(frames):
image.seek(frame_index)
pixels = encoder.convert(image.resize((width, height)), path).getdata()
Expand Down
Loading