Mercurial > lcfOS
view experiments/qemu_vexpress_a9/make_image.py @ 370:f86e79246602
Remove null stdio
author | Windel Bouwman |
---|---|
date | Fri, 21 Mar 2014 11:57:32 +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()