Mercurial > lcfOS
comparison 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 |
comparison
equal
deleted
inserted
replaced
339:6ee17c4dd6b8 | 340:c7cc54c0dfdf |
---|---|
1 | |
2 from PyQt5.QtGui import QImage, QGuiApplication, qRed, qBlue, qGreen | |
3 | |
4 app = QGuiApplication([]) | |
5 img = QImage('../../python/ide/icons/hardware.png') | |
6 #print(img) | |
7 | |
8 f = open('image.c', 'w') | |
9 print('typedef unsigned short uint16;',file=f) | |
10 print('uint16 image_width = {};'.format(img.width()), file=f) | |
11 print('uint16 image_height = {};'.format(img.height()), file=f) | |
12 print('uint16 image_data[{}] = {{'.format(img.width()*img.height()+1), file=f) | |
13 for y in range(img.height()): | |
14 for x in range(img.width()): | |
15 pix = img.pixel(x, y) | |
16 #print(qRed(pix)) | |
17 r = qRed(pix) >> 3 | |
18 g = qGreen(pix) >> 2 | |
19 b = qBlue(pix) >> 3 | |
20 u16 = (r << 11) | (g << 6) | b | |
21 assert u16 in range(2**16) | |
22 print(' {},'.format(hex(u16)),file=f) | |
23 | |
24 print('0x0};', file=f) | |
25 f.close() | |
26 |