annotate experiments/qemu_vexpress_a9/make_image.py @ 341:4d204f6f7d4e devel

Rewrite of assembler parts
author Windel Bouwman
date Fri, 28 Feb 2014 18:07:14 +0100
parents c7cc54c0dfdf
children
rev   line source
340
c7cc54c0dfdf Test featurebranch
Windel Bouwman
parents:
diff changeset
1
c7cc54c0dfdf Test featurebranch
Windel Bouwman
parents:
diff changeset
2 from PyQt5.QtGui import QImage, QGuiApplication, qRed, qBlue, qGreen
c7cc54c0dfdf Test featurebranch
Windel Bouwman
parents:
diff changeset
3
c7cc54c0dfdf Test featurebranch
Windel Bouwman
parents:
diff changeset
4 app = QGuiApplication([])
c7cc54c0dfdf Test featurebranch
Windel Bouwman
parents:
diff changeset
5 img = QImage('../../python/ide/icons/hardware.png')
c7cc54c0dfdf Test featurebranch
Windel Bouwman
parents:
diff changeset
6 #print(img)
c7cc54c0dfdf Test featurebranch
Windel Bouwman
parents:
diff changeset
7
c7cc54c0dfdf Test featurebranch
Windel Bouwman
parents:
diff changeset
8 f = open('image.c', 'w')
c7cc54c0dfdf Test featurebranch
Windel Bouwman
parents:
diff changeset
9 print('typedef unsigned short uint16;',file=f)
c7cc54c0dfdf Test featurebranch
Windel Bouwman
parents:
diff changeset
10 print('uint16 image_width = {};'.format(img.width()), file=f)
c7cc54c0dfdf Test featurebranch
Windel Bouwman
parents:
diff changeset
11 print('uint16 image_height = {};'.format(img.height()), file=f)
c7cc54c0dfdf Test featurebranch
Windel Bouwman
parents:
diff changeset
12 print('uint16 image_data[{}] = {{'.format(img.width()*img.height()+1), file=f)
c7cc54c0dfdf Test featurebranch
Windel Bouwman
parents:
diff changeset
13 for y in range(img.height()):
c7cc54c0dfdf Test featurebranch
Windel Bouwman
parents:
diff changeset
14 for x in range(img.width()):
c7cc54c0dfdf Test featurebranch
Windel Bouwman
parents:
diff changeset
15 pix = img.pixel(x, y)
c7cc54c0dfdf Test featurebranch
Windel Bouwman
parents:
diff changeset
16 #print(qRed(pix))
c7cc54c0dfdf Test featurebranch
Windel Bouwman
parents:
diff changeset
17 r = qRed(pix) >> 3
c7cc54c0dfdf Test featurebranch
Windel Bouwman
parents:
diff changeset
18 g = qGreen(pix) >> 2
c7cc54c0dfdf Test featurebranch
Windel Bouwman
parents:
diff changeset
19 b = qBlue(pix) >> 3
c7cc54c0dfdf Test featurebranch
Windel Bouwman
parents:
diff changeset
20 u16 = (r << 11) | (g << 6) | b
c7cc54c0dfdf Test featurebranch
Windel Bouwman
parents:
diff changeset
21 assert u16 in range(2**16)
c7cc54c0dfdf Test featurebranch
Windel Bouwman
parents:
diff changeset
22 print(' {},'.format(hex(u16)),file=f)
c7cc54c0dfdf Test featurebranch
Windel Bouwman
parents:
diff changeset
23
c7cc54c0dfdf Test featurebranch
Windel Bouwman
parents:
diff changeset
24 print('0x0};', file=f)
c7cc54c0dfdf Test featurebranch
Windel Bouwman
parents:
diff changeset
25 f.close()
c7cc54c0dfdf Test featurebranch
Windel Bouwman
parents:
diff changeset
26