Files
amiga/AmberMonitor/icon.py
T

23 lines
1.1 KiB
Python

from pathlib import Path
from PIL import Image,ImageDraw,ImageFont
import struct
p=Path('C:/Amiga/HD0/Utilities/AmberMonitor')
h=bytearray(Path('C:/Amiga/HD0/System/Shell.info').read_bytes()[:78])
def u16(n):return struct.pack('>H',n)
def u32(n):return struct.pack('>I',n&0xffffffff)
h[12:16]=u16(48)+u16(40);h[16:18]=u16(6);h[48]=3
for off in (22,26):h[off:off+4]=u32(1)
for off in (44,50,54,66,70):h[off:off+4]=u32(0)
h[58:66]=u32(-1)+u32(-1);h[74:78]=u32(65536)
data=bytearray(h)
for selected in (False,True):
im=Image.new('P',(48,40),0);d=ImageDraw.Draw(im)
d.rounded_rectangle((2,1,45,35),radius=3,fill=2,outline=1 if selected else 3,width=2)
for x,height in [(8,6),(14,12),(20,9),(26,19),(32,14),(38,23)]:d.rectangle((x,30-height,x+3,30),fill=3 if height<20 else 1)
d.line((6,32,41,32),fill=1);d.rectangle((18,36,30,38),fill=3)
data+=u16(0)+u16(0)+u16(48)+u16(40)+u16(2)+u32(1)+bytes([3,0])+u32(0)
for plane in range(2):
for y in range(40):
for x in range(0,48,8):data.append(sum((128>>i) if im.getpixel((x+i,y))&(1<<plane) else 0 for i in range(8)))
(p/'Monitor.info').write_bytes(data)