Merge pull request #1738 from pijyoi/fix_font

use Format_RGB32 when using QImage as paint device
This commit is contained in:
Ogi Moore 2021-04-24 09:43:42 -07:00 committed by GitHub
commit cf95964678
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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)