Alpha for rgbXXX modes

This commit is contained in:
Casey 2024-07-04 12:28:12 +03:00
parent 9f525df0ff
commit 13c628e00f
Signed by: hkc
GPG Key ID: F0F6CFE11CDB0960
1 changed files with 7 additions and 3 deletions

View File

@ -116,7 +116,9 @@ async def amain():
with Image.open(elem["path"]).convert("RGB") as im:
for y in range(im.height):
for x in range(im.width):
r, g, b = im.getpixel((x, y)) # type: ignore
r, g, b, a = im.getpixel((x, y)) # type: ignore
if a < 128:
continue
pocket_x = x + ox
pocket_y = y + oy
@ -126,10 +128,12 @@ async def amain():
mgr.difference[ndx_start + 2] = b > 128
elif elem["type"] == "rgb565":
ox, oy = elem["x"], elem["y"]
with Image.open(elem["path"]).convert("RGB") as im:
with Image.open(elem["path"]).convert("RGBA") as im:
for y in range(im.height):
for x in range(im.width):
r, g, b = im.getpixel((x, y)) # type: ignore
r, g, b, a = im.getpixel((x, y)) # type: ignore
if a < 128:
continue
ndx_start: int = (x + ox + (y + oy) * 250) * 16
color = (r >> 3) << 13
color |= (g >> 2) << 5