From 13c628e00ff80737b983065935c76cd504c6bb51 Mon Sep 17 00:00:00 2001 From: hkc Date: Thu, 4 Jul 2024 12:28:12 +0300 Subject: [PATCH] Alpha for rgbXXX modes --- async-bot.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/async-bot.py b/async-bot.py index 4b76a23..9f83429 100644 --- a/async-bot.py +++ b/async-bot.py @@ -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