Mercurial > lcfOS
view experiments/qemu_vexpress_a9/make_image.py @ 357:818be710e13d
Added acceptance function to burg
author | Windel Bouwman |
---|---|
date | Fri, 14 Mar 2014 15:14:29 +0100 |
parents | c7cc54c0dfdf |
children |
line wrap: on
line source
from PyQt5.QtGui import QImage, QGuiApplication, qRed, qBlue, qGreen app = QGuiApplication([]) img = QImage('../../python/ide/icons/hardware.png') #print(img) f = open('image.c', 'w') print('typedef unsigned short uint16;',file=f) print('uint16 image_width = {};'.format(img.width()), file=f) print('uint16 image_height = {};'.format(img.height()), file=f) print('uint16 image_data[{}] = {{'.format(img.width()*img.height()+1), file=f) for y in range(img.height()): for x in range(img.width()): pix = img.pixel(x, y) #print(qRed(pix)) r = qRed(pix) >> 3 g = qGreen(pix) >> 2 b = qBlue(pix) >> 3 u16 = (r << 11) | (g << 6) | b assert u16 in range(2**16) print(' {},'.format(hex(u16)),file=f) print('0x0};', file=f) f.close()