From fbc86cd2c5b7057c0d420aa8f9ec28c4608f06e6 Mon Sep 17 00:00:00 2001 From: KIU Shueng Chuan Date: Fri, 23 Apr 2021 18:29:27 +0800 Subject: [PATCH] use Format_RGB32 when using QImage as paint device this allows sub-pixel font antialiasing to take place. --- pyqtgraph/widgets/RemoteGraphicsView.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/pyqtgraph/widgets/RemoteGraphicsView.py b/pyqtgraph/widgets/RemoteGraphicsView.py index ccc6e5c8..2989f184 100644 --- a/pyqtgraph/widgets/RemoteGraphicsView.py +++ b/pyqtgraph/widgets/RemoteGraphicsView.py @@ -80,17 +80,14 @@ class RemoteGraphicsView(QtGui.QWidget): self.shm = mmap.mmap(-1, size, self.shmtag) ## can't use tmpfile on windows because the file can only be opened once. else: self.shm = mmap.mmap(self.shmFile.fileno(), size, mmap.MAP_SHARED, mmap.PROT_READ) - self.shm.seek(0) - data = self.shm.read(w*h*4) - self._img = QtGui.QImage(data, w, h, QtGui.QImage.Format_ARGB32) - self._img.data = data # data must be kept alive or PySide 1.2.1 (and probably earlier) will crash. + self._img = QtGui.QImage(self.shm, w, h, QtGui.QImage.Format.Format_RGB32).copy() self.update() def paintEvent(self, ev): if self._img is None: return p = QtGui.QPainter(self) - p.drawImage(self.rect(), self._img, QtCore.QRect(0, 0, self._img.width(), self._img.height())) + p.drawImage(self.rect(), self._img, self._img.rect()) p.end() def serialize_mouse_enum(self, *args): @@ -243,7 +240,7 @@ class Renderer(GraphicsView): # PySide2, PySide6 img_ptr = self.shm - self.img = QtGui.QImage(img_ptr, iwidth, iheight, QtGui.QImage.Format_ARGB32) + self.img = QtGui.QImage(img_ptr, iwidth, iheight, QtGui.QImage.Format.Format_RGB32) self.img.setDevicePixelRatio(dpr) self.img.fill(0xffffffff)