Mercurial > lcfOS
view experiments/qemu_vexpress_a9/make_image.py @ 372:68841f9ab96c
Added yet another test snippet
author | Windel Bouwman |
---|---|
date | Fri, 21 Mar 2014 12:33:30 +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()