Fixed rgb565 mode

This commit is contained in:
Casey 2024-07-05 12:02:12 +03:00
parent 741b762c1e
commit aa959b1e71
Signed by: hkc
GPG Key ID: F0F6CFE11CDB0960
3 changed files with 18 additions and 20 deletions

View File

@ -226,10 +226,10 @@ async def amain() -> None:
if a < 128: if a < 128:
continue continue
ndx_start = (x + ox + (y + oy) * 577) * 3 start_ndx = (x + ox + (y + oy) * 577) * 3
mgr.put_index(ndx_start, r > 128) mgr.put_index(start_ndx, r > 128)
mgr.put_index(ndx_start + 1, g > 128) mgr.put_index(start_ndx + 1, g > 128)
mgr.put_index(ndx_start + 2, b > 128) mgr.put_index(start_ndx + 2, b > 128)
elif elem["type"] == "rgb565": elif elem["type"] == "rgb565":
ox, oy = elem["x"], elem["y"] ox, oy = elem["x"], elem["y"]
with Image.open(elem["path"]).convert("RGBA") as im: with Image.open(elem["path"]).convert("RGBA") as im:
@ -238,14 +238,19 @@ async def amain() -> None:
r, g, b, a = im.getpixel((x, y)) # type: ignore r, g, b, a = im.getpixel((x, y)) # type: ignore
if a < 128: if a < 128:
continue continue
ndx_start = (x + ox + (y + oy) * 250) * 16
color: int = (r >> 3) << 13 offset: int = (x + ox + (y + oy) * 250) * 16
color |= (g >> 2) << 5
color |= b >> 3 rgb: int = (r >> 3) << 11
rgb |= (g >> 2) << 5
rgb |= (b >> 3)
color: int = (rgb & 0xFF) << 8
color |= (rgb >> 8)
for i in range(16): for i in range(16):
mgr.put_index( mgr.put_index(
ndx_start + i, ((color >> i) & 1) > 0 offset + i, ((color << i) & 0x8000) > 0
) )
elif elem["type"] == "rect": elif elem["type"] == "rect":
for y in range(elem["y"], elem["y"] + elem["h"]): for y in range(elem["y"], elem["y"] + elem["h"]):

BIN
pictures/niko.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

View File

@ -50,12 +50,6 @@
} }
], ],
"elements": [ "elements": [
{
"type": "blob",
"path": "./pictures/bit.txt",
"offset": 16384,
"length": 12632
},
{ {
"type": "image", "type": "image",
"path": "./pictures/kangel.png", "path": "./pictures/kangel.png",
@ -88,11 +82,10 @@
"y": 256 "y": 256
}, },
{ {
"type": "animation", "type": "rgb565",
"path": "./pictures/loading.gif", "path": "./pictures/niko.png",
"x": 436, "x": 48,
"y": 436, "y": 12
"spf": 10
} }
] ]
} }