Files
amiga/AmberMod/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/AmberMod')
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(131072)
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)
d.ellipse((8,6,35,32),fill=3,outline=1);d.ellipse((16,14,27,25),fill=2,outline=1);d.polygon(((21,17),(21,23),(26,20)),fill=1);d.rectangle((36,9,39,30),fill=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/'ModPlayer.info').write_bytes(data)