ibis-os/gfx/cvbmp.py

18 lines
421 B
Python

from PIL import Image
im = Image.open('cursor.bmp')
pixels = list(im.getdata())
w, h = im.size
with open('gfxd_cursor.asm', 'w') as f:
f.write(f'gfxd_cursor_dim: db {w}, {h}\n')
f.write('gfxd_cursor: db ')
for px in pixels:
if px == (255, 255, 255, 255):
c = '0x0F'
elif px == (0, 0, 0, 255):
c = '0x00'
else:
c = '0xFF'
f.write(f'{c}, ')