fix(script): fix png to bin converter to take magic into consideration (#5285)

Signed-off-by: Xu Xingliang <xuxingliang@xiaomi.com>
This commit is contained in:
Neo Xu
2024-01-11 18:14:32 +08:00
committed by GitHub
parent 973285f33e
commit 087a06b2c9

View File

@@ -341,9 +341,9 @@ class LVGLImageHeader:
raise FormatError("invalid header length")
try:
self.cf = ColorFormat(data[0] & 0x1f) # color format
self.cf = ColorFormat(data[1] & 0x1f) # color format
except ValueError as exc:
raise FormatError("invalid color format") from exc
raise FormatError(f"invalid color format: {hex(data[0])}") from exc
self.w = int.from_bytes(data[4:6], 'little')
self.h = int.from_bytes(data[6:8], 'little')
self.stride = int.from_bytes(data[8:10], 'little')