From d67464af72166ed50828272ad6a804474f4ffcbb Mon Sep 17 00:00:00 2001 From: Luke Campagnola Date: Mon, 17 Feb 2014 20:02:03 -0500 Subject: [PATCH] Update imageToArray to support Py2.6 + Qt 4.10 --- pyqtgraph/functions.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pyqtgraph/functions.py b/pyqtgraph/functions.py index 99c45606..7687814f 100644 --- a/pyqtgraph/functions.py +++ b/pyqtgraph/functions.py @@ -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)