Mercurial > lcfOS
diff experiments/qemu_vexpress_a9/make_image.py @ 340:c7cc54c0dfdf devel
Test featurebranch
author | Windel Bouwman |
---|---|
date | Sun, 23 Feb 2014 16:24:01 +0100 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/experiments/qemu_vexpress_a9/make_image.py Sun Feb 23 16:24:01 2014 +0100 @@ -0,0 +1,26 @@ + +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() +