Update imageToArray to support Py2.6 + Qt 4.10

This commit is contained in:
Luke Campagnola 2014-02-17 20:02:03 -05:00
parent 210d07027e
commit d67464af72

View File

@ -993,6 +993,10 @@ def imageToArray(img, copy=False, transpose=True):
else:
ptr.setsize(img.byteCount())
arr = np.asarray(ptr)
if img.byteCount() != arr.size * arr.itemsize:
# Required for Python 2.6, PyQt 4.10
# If this works on all platforms, then there is no need to use np.asarray..
arr = np.frombuffer(ptr, np.ubyte, img.byteCount())
if fmt == img.Format_RGB32:
arr = arr.reshape(img.height(), img.width(), 3)