From 940c7e5e91427bd80f0584b27b772d9b5f5ef498 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20Weigert?= Date: Mon, 9 Sep 2019 22:00:17 +0200 Subject: [PATCH] Fixed x >= im.width bug. Hand improved gfx/falafue_logo_44x11 font. --- gfx/falafue_logo_44x11.png | Bin 368 -> 364 bytes led-badge-11x44.py | 25 +++++++++++++------------ 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/gfx/falafue_logo_44x11.png b/gfx/falafue_logo_44x11.png index 8306095c3f01de43a7ee01c4190b437f5ea9f1fc..5d4df59497811b26b81aa37c4aa38bfdb169d3d6 100644 GIT binary patch delta 250 zcmV0_*~iQV9tO6FV(S5kM1>TP%OjNkl@IF$c?loRp} zD^)w;_fH;gimjD0}!PD$Dg0&z$pI6vbfvSpH>oPEsZoX~Yv|v16 zvy>7TRc0lo6QHyX&ZR4{7jzW@LL07*qoM6N<$g4$Yi Anop!=yXyvvAjnWzbBqE#d9vhuY2>SR`WB5v;caCab zXX~G#0^on?Y8}^9x1C>U%Hr3uHiWQe*z()T>RSw_l(r1}LahSo*N&{qr8{Hw&O0n3 zv@FY|z2i8x=g^_%eLrgPbzNai*NVvDzEVE*=Xu`5J|bT4da5(8HUIzs07*qoM6N<$ Ef+S{qZU6uP diff --git a/led-badge-11x44.py b/led-badge-11x44.py index 46389c9..cdb38f7 100755 --- a/led-badge-11x44.py +++ b/led-badge-11x44.py @@ -323,21 +323,22 @@ def bitmap_img(file): buf = array('B') cols = int((im.width+7)/8) for col in range(cols): - for row in range(11): + for row in range(11): # [0..10] byte_val = 0 - for bit in range(8): + for bit in range(8): # [0..7] bit_val = 0 x = 8*col+bit - pixel_color = im.getpixel( (x, row) ) - if isinstance(pixel_color, tuple): - monochrome_color = sum(pixel_color[:3]) / len(pixel_color[:3]) - elif isinstance(pixel_color, int): - monochrome_color = pixel_color - else: - sys.exit("%s: Unknown pixel format detected (%s)!" % (file, pixel_color)) - if x < im.width and monochrome_color > 127: - bit_val = 1 << (7-bit) - byte_val += bit_val + if x < im.width: + pixel_color = im.getpixel( (x, row) ) + if isinstance(pixel_color, tuple): + monochrome_color = sum(pixel_color[:3]) / len(pixel_color[:3]) + elif isinstance(pixel_color, int): + monochrome_color = pixel_color + else: + sys.exit("%s: Unknown pixel format detected (%s)!" % (file, pixel_color)) + if monochrome_color > 127: + bit_val = 1 << (7-bit) + byte_val += bit_val buf.append(byte_val) im.close() return (buf, cols)