File tree Expand file tree Collapse file tree 1 file changed +8
-5
lines changed Expand file tree Collapse file tree 1 file changed +8
-5
lines changed Original file line number Diff line number Diff line change 4
4
5
5
import ctypes
6
6
7
+ from qimage2ndarray import array2qimage
8
+
7
9
from matplotlib .transforms import Bbox
8
10
9
11
from .. import cbook
@@ -52,14 +54,15 @@ def paintEvent(self, event):
52
54
buf = cbook ._unmultiplied_rgba8888_to_premultiplied_argb32 (
53
55
memoryview (reg ))
54
56
55
- # clear the widget canvas
56
- painter .eraseRect (rect )
57
-
58
- qimage = QtGui .QImage (buf , buf .shape [1 ], buf .shape [0 ],
59
- QtGui .QImage .Format_ARGB32_Premultiplied )
57
+ # create a QImage from the array buffer
58
+ qimage = array2qimage (buf )
60
59
if hasattr (qimage , 'setDevicePixelRatio' ):
61
60
# Not available on Qt4 or some older Qt5.
62
61
qimage .setDevicePixelRatio (self ._dpi_ratio )
62
+
63
+ # clear the widget canvas
64
+ painter .eraseRect (rect )
65
+
63
66
origin = QtCore .QPoint (left , top )
64
67
painter .drawImage (origin / self ._dpi_ratio , qimage )
65
68
# Adjust the buf reference count to work around a memory
You can’t perform that action at this time.
0 commit comments