circuitpython/tests/testlib/dump_bitmap.py
Jeff Epler 36411203ff
Add bitmapfilter.mix
This allows operations between channels in an image. It can be used for
the following use cases:
 * Conversion to B&W or sepia
 * Adding color casts
 * Mixing or swapping arbitrary channels
 * Inverting or scaling arbitrary channels
2024-01-09 15:00:42 -06:00

17 lines
464 B
Python

palette = list("█▓▓▒▒░░·")
def dump_bitmap(b, shifts=(0,)):
for i in range(b.height):
for shift in shifts:
for j in range(b.width):
# Bit order is gggBBBBBRRRRRGGG" so shift of 0 takes high order bits of G
p = (b[j, i] >> shift) & 7
print(end=palette[p])
print(end=" ")
print()
print()
def dump_bitmap_rgb_swapped(b):
dump_bitmap(b, (5, 0, 10))