Merge pull request #1795 from pijyoi/avoid_writable_qimage
don't rely on QImage-wrapped buffer being writable
This commit is contained in:
commit
c0b9f3e26e
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user