File: compile.py

package info (click to toggle)
python-pyqtgraph 0.11.1-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 4,684 kB
  • sloc: python: 45,678; makefile: 115; ansic: 40
file content (19 lines) | stat: -rw-r--r-- 627 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# -*- coding: utf-8 -*-
import numpy as np
from PyQt4 import QtGui
import os, pickle, sys

path = os.path.abspath(os.path.split(__file__)[0])
pixmaps = {}
for f in os.listdir(path):
    if not f.endswith('.png'):
        continue
    print(f)
    img = QtGui.QImage(os.path.join(path, f))
    ptr = img.bits()
    ptr.setsize(img.byteCount())
    arr = np.asarray(ptr).reshape(img.height(), img.width(), 4).transpose(1,0,2)
    pixmaps[f] = pickle.dumps(arr)
ver = sys.version_info[0]
with open(os.path.join(path, 'pixmapData_%d.py' % (ver, )), 'w') as fh:
    fh.write("import numpy as np; pixmapData=%s" % (repr(pixmaps), ))