From 8991dd681135ada5d39a20be11e7e2c135de58c7 Mon Sep 17 00:00:00 2001 From: Rai <58925163+rai68@users.noreply.github.com> Date: Thu, 4 Apr 2024 03:04:31 +1000 Subject: [PATCH] Update components.py this allows plugins / ui elements of bitmap to be inverted for plugins etc Signed-off-by: Rai <58925163+rai68@users.noreply.github.com> --- pwnagotchi/ui/components.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pwnagotchi/ui/components.py b/pwnagotchi/ui/components.py index b6d4db49..763f510b 100644 --- a/pwnagotchi/ui/components.py +++ b/pwnagotchi/ui/components.py @@ -10,13 +10,17 @@ class Widget(object): def draw(self, canvas, drawer): raise Exception("not implemented") - +# canvas.paste: https://pillow.readthedocs.io/en/stable/reference/Image.html#PIL.Image.Image.paste +# takes mask variable, to identify color system. (not used for pwnagotchi yet) +# Pwn should use "1" since its mainly black or white displays. class Bitmap(Widget): def __init__(self, path, xy, color=0): super().__init__(xy, color) self.image = Image.open(path) def draw(self, canvas, drawer): + if self.color = 0xFF: + self.image = ImageOps.invert(self.image) canvas.paste(self.image, self.xy)