8000 Directly get the size of the renderer buffer from the renderer. · matplotlib/matplotlib@c624d57 · GitHub
[go: up one dir, main page]

Skip to content

Commit c624d57

Browse files
committed
Directly get the size of the renderer buffer from the renderer.
... rather than trying to compute it outselves, which can lead to off-by-one errors due to the use of floats in the initial buffer request.
1 parent 38476fd commit c624d57

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