ibis-os/gfx/cvbmp.py

18 lines
421 B
Python
Raw Normal View History

2024-07-25 17:28:01 +00:00
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:
2024-07-25 18:20:57 +00:00
f.write(f'gfxd_cursor_dim: db {w}, {h}\n')
f.write('gfxd_cursor: db ')
2024-07-25 17:28:01 +00:00
for px in pixels:
if px == (255, 255, 255, 255):
c = '0x0F'
elif px == (0, 0, 0, 255):
c = '0x00'
else:
c = '0xFF'
2024-07-25 18:20:57 +00:00
f.write(f'{c}, ')