From c80bfb334cb78303b866655149f24060aa392d89 Mon Sep 17 00:00:00 2001 From: Luke Campagnola Date: Mon, 11 Feb 2013 16:38:13 -0500 Subject: [PATCH] Fix for new QImage API in PyQt 4.9.6 --- pyqtgraph/functions.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/pyqtgraph/functions.py b/pyqtgraph/functions.py index 467649e8..6fc4cbd8 100644 --- a/pyqtgraph/functions.py +++ b/pyqtgraph/functions.py @@ -951,8 +951,15 @@ def makeQImage(imgData, alpha=None, copy=True, transpose=True): ch = ctypes.c_char.from_buffer(imgData, 0) img = QtGui.QImage(ch, imgData.shape[1], imgData.shape[0], imgFormat) else: - addr = ctypes.addressof(ctypes.c_char.from_buffer(imgData, 0)) - img = QtGui.QImage(addr, imgData.shape[1], imgData.shape[0], imgFormat) + #addr = ctypes.addressof(ctypes.c_char.from_buffer(imgData, 0)) + ## PyQt API for QImage changed between 4.9.3 and 4.9.6 (I don't know exactly which version it was) + ## So we first attempt the 4.9.6 API, then fall back to 4.9.3 + addr = ctypes.c_char.from_buffer(imgData, 0) + try: + img = QtGui.QImage(addr, imgData.shape[1], imgData.shape[0], imgFormat) + except TypeError: + addr = ctypes.addressof(addr) + img = QtGui.QImage(addr, imgData.shape[1], imgData.shape[0], imgFormat) img.data = imgData return img #try: