Merge pull request #1795 from pijyoi/avoid_writable_qimage

don't rely on QImage-wrapped buffer being writable
This commit is contained in:
Ogi Moore 2021-06-01 23:05:01 -07:00 committed by GitHub
commit c0b9f3e26e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 5 deletions

View File

@ -1423,10 +1423,6 @@ def ndarray_to_qimage(arr, fmt):
h, w = arr.shape[:2]
bytesPerLine = arr.strides[0]
qimg = QtGui.QImage(img_ptr, w, h, bytesPerLine, fmt)
# Note that the bindings that support ndarray directly already hold a reference
# to it. The manual reference below is only needed for those bindings that take
# in a raw pointer.
qimg.data = arr
return qimg

View File

@ -235,7 +235,7 @@ class ImageItem(GraphicsObject):
self._processingBuffer = self._xp.empty(shape[:2] + (4,), dtype=self._xp.ubyte)
else:
self._processingBuffer = self._displayBuffer
self.qimage = fn.makeQImage(self._displayBuffer, transpose=False, copy=False)
self.qimage = None
def setImage(self, image=None, autoLevels=None, **kargs):
"""
@ -471,6 +471,7 @@ class ImageItem(GraphicsObject):
fn.makeARGB(image, lut=lut, levels=levels, output=self._processingBuffer)
if self._xp == getCupy():
self._processingBuffer.get(out=self._displayBuffer)
self.qimage = fn.ndarray_to_qimage(self._displayBuffer, QtGui.QImage.Format.Format_ARGB32)
self._renderRequired = False
self._unrenderable = False