def __setstate__(self, state): (x, y), patch, self._flags, self._occurrenceCount, color = state if self.flag(self.FLAG_RECT): self._pos = QtCore.QPointF(x, y) # (float pos) w, h = patch self._image = QtCore.QSizeF(w, h) else: self._pos = QtCore.QPoint(x, y) # (integer pos) h, w = patch.shape self._image = QtGui.QImage(w, h, QtGui.QImage.Format_ARGB32) if self.flag(self.FLAG_MONOCHROME): qimage2ndarray.raw_view(self._image)[:] = color qimage2ndarray.alpha_view(self._image)[:] = patch else: qimage2ndarray.raw_view(self._image)[:] = patch self._pixmap = None self._color = QtGui.QColor(color)
def ndarray(self): assert not self.flag(self.FLAG_RECT) if self.flag(self.FLAG_MONOCHROME): return qimage2ndarray.alpha_view(self._image) return qimage2ndarray.raw_view(self._image)