From 1571d11322d8d9b04fb7052c2e053292b5fc0ec2 Mon Sep 17 00:00:00 2001 From: Zeilenschubser Date: Sun, 28 Dec 2025 17:20:12 +0100 Subject: [PATCH] animation converter v1 --- anim.py | 93 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 anim.py diff --git a/anim.py b/anim.py new file mode 100644 index 0000000..dbe803d --- /dev/null +++ b/anim.py @@ -0,0 +1,93 @@ +from PIL import Image +STATIC = 1 +ANIMATION = 2 + +startx, starty = 16,25 + +image_on = Image.open("file_on_m.bmp") +image_off = Image.open("file_off_m.bmp") +# im = image.convert(mode='') +# im_pixels = im.load() +# # access pixels via [x, y] +# for col in range(im.size[0]): +# for row in range(im.size[1]): +# brightness = sum(im_pixels[col, row]) +# if brightness < 255*2: +# im_pixels[col, row] = (0, 0, 0) +# else: +# im_pixels[col, row] = (255,255,255) +# im.save('file_on_m.bmp') + + +def bmp_to_bitmap_fn(im): + def fn(img): + x = [xc if sum(im.getpixel((xc,yc))) == 0 else None for xc in range(im.size[0]) for yc in range(im.size[1])] + y = [yc if sum(im.getpixel((xc,yc))) == 0 else None for xc in range(im.size[0]) for yc in range(im.size[1])] + x = list(filter(lambda x: x!=None, x)) + y = list(filter(lambda y: y!=None, y)) + xmin, xmax = min(x), max(x) + ymin, ymax = min(y), max(y) + # print(xmin, xmax, ymin, ymax) + xsize = (xmax-xmin) + ysize = (ymax-ymin) + print(len(img)) + for y in range(ysize): + for x in range(0,xsize): + # print(xmin+x+bit, ymin+y) + if im.size[0] >= x and sum(im.getpixel((xmin+x,ymin+y))) == 0: + # print( im.size[0], x,x+bit, (xmin+x+bit,ymin+y)) + pos = ((y * xsize) + x) // 8 + bit = ((y * xsize) + x) % 8 + print(pos, 1<