https://bitbucket.org/hudson/magic-lantern
Raw File
Tip revision: 4902db380d34a7d311dce1ed227ffaee68c2683f authored by a1ex on 19 June 2016, 18:37:12 UTC
Close branch 6d-button-info.
Tip revision: 4902db3
make-icons.py
from PIL import Image
import os

W = 46
H = 42

# do not encode outer pixels, to save some RAM
Xpad = 3
Ypad = 4
Hpadded = H - Ypad*2
Wpadded = W - Xpad*2

icons = [
    'audio.png',
    'expo.png',
    'overlay.png',
    'movie.png',
    'shoot.png',
    'focus.png',
    'display.png',
    'prefs.png',
    'debug.png',
    'info.png',
    'mymenu.png',
    'script.png',
    'Q-forward.png',
    'Q-back.png',
    'forward.png',
    'modules.png',
    'modified.png',
    'games.png',
]

# On low-res screens, the audio and focus icons are aliasing
icons_lowres = [
    'audio-lowres.png',
    'expo.png',
    'overlay.png',
    'movie.png',
    'shoot.png',
    'focus-lowres.png',
    'display.png',
    'prefs.png',
    'debug.png',
    'info.png',
    'mymenu.png',
    'script.png',
    'Q-forward.png',
    'Q-back.png',
    'forward.png',
    'modules.png',
    'modified.png',
    'games.png',
]


def process(icons, outfile):
    tmp = open("ico.in", "w")
    k = 0
    for ico in icons:
        print >> tmp, '%s = ' % chr(ord('a') + k)
        k += 1
        im = Image.open(ico).convert("1")
        for y in range(Hpadded):
            for x in range(Wpadded):
                tmp.write("#" if im.getpixel((x+Xpad, y+Ypad)) else " ")
            print >> tmp, ""
        print >> tmp, ""

    tmp.close()

    os.system("perl mkfont-canon < ico.in > %s -width %d -height %d" % (outfile, Wpadded, Hpadded))

process(icons, "ico.c")
process(icons_lowres, "ico-lowres.c")

os.system("diff -D CONFIG_LOW_RESOLUTION_DISPLAY ico.c ico-lowres.c > ../src/ico.c")
back to top