Merge pull request #17 from LinusCDE/master

Support for 1-Bit color depth and ignore transparency

Never tried with monochrome input :-) much better code there now! Thank you!
pull/1/head
Jürgen Weigert 5 years ago committed by GitHub
commit bac0465209
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 9
      led-badge-11x44.py

@ -328,7 +328,14 @@ def bitmap_img(file):
for bit in range(8):
bit_val = 0
x = 8*col+bit
if x < im.width and sum(im.getpixel( (x, row) )) > 384:
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
buf.append(byte_val)

Loading…
Cancel
Save