8000 Merge pull request #11731 from anntzer/qt-buffer-off-by-one · matplotlib/matplotlib@23420a4 · GitHub
[go: up one dir, main page]

Skip to content

Commit 23420a4

Browse files
authored
Merge pull request #11731 from anntzer/qt-buffer-off-by-one
MNT: Directly get the size of the renderer buffer from the renderer.
2 parents 38476fd + c624d57 commit 23420a4

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

lib/matplotlib/backends/backend_qt5agg.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,9 @@ def paintEvent(self, event):
4848
[[left, self.renderer.height - (top + height * self._dpi_ratio)],
4949
[left + width * self._dpi_ratio, self.renderer.height - top]])
5050
reg = self.copy_from_bbox(bbox)
51-
buf = reg.to_string_argb()
51+
buf = memoryview(reg)
5252
qimage = QtGui.QImage(
53-
buf, width * self._dpi_ratio, height * self._dpi_ratio,
54-
QtGui.QImage.Format_ARGB32)
53+
buf, buf.shape[1], buf.shape[0], QtGui.QImage.Format_RGBA8888)
5554
if hasattr(qimage, 'setDevicePixelRatio'):
5655
# Not available on Qt4 or some older Qt5.
5756
qimage.setDevicePixelRatio(self._dpi_ratio)

0 commit comments

Comments
 (0)
0