23
23
CloseEvent , KeyEvent , LocationEvent , MouseEvent , ResizeEvent )
24
24
from matplotlib ._pylab_helpers import Gcf
25
25
from . import _tkagg
26
+ from ._tkagg import TK_PHOTO_COMPOSITE_OVERLAY , TK_PHOTO_COMPOSITE_SET
26
27
27
28
28
29
_log = logging .getLogger (__name__ )
@@ -51,9 +52,6 @@ def _restore_foreground_window_at_end():
51
52
# Initialize to a non-empty string that is not a Tcl command
52
53
_blit_tcl_name = "mpl_blit_" + uuid .uuid4 ().hex
53
54
54
- TK_PHOTO_COMPOSITE_OVERLAY = 0 # apply transparency rules pixel-wise
55
- TK_PHOTO_COMPOSITE_SET = 1 # set image buffer directly
56
-
57
55
58
56
def _blit (argsid ):
59
57
"""
@@ -62,11 +60,11 @@ def _blit(argsid):
62
60
*argsid* is a unique string identifier to fetch the correct arguments from
63
61
the ``_blit_args`` dict, since arguments cannot be passed directly.
64
62
"""
65
- photoimage , dataptr , offsets , bboxptr , comp_rule = _blit_args .pop (argsid )
63
+ photoimage , data , offsets , bbox , comp_rule = _blit_args .pop (argsid )
66
64
if not photoimage .tk .call ("info" , "commands" , photoimage ):
67
65
return
68
- _tkagg .blit (photoimage .tk .interpaddr (), str (photoimage ), dataptr ,
69
- comp_rule , offsets , bboxptr )
66
+ _tkagg .blit (photoimage .tk .interpaddr (), str (photoimage ), data , comp_rule , offsets ,
67
+ bbox )
70
68
71
69
72
70
def blit (photoimage , aggimage , offsets , bbox = None ):
@@ -87,7 +85,6 @@ def blit(photoimage, aggimage, offsets, bbox=None):
87
85
"""
88
86
data = np .asarray (aggimage )
89
87
height , width = data .shape [:2 ]
90
- dataptr = (height , width , data .ctypes .data )
91
88
if bbox is not None :
92
89
(x1 , y1 ), (x2 , y2 ) = bbox .__array__ ()
93
90
x1 = max (math .floor (x1 ), 0 )
@@ -109,7 +106,7 @@ def blit(photoimage, aggimage, offsets, bbox=None):
109
106
110
107
# tkapp.call coerces all arguments to strings, so to avoid string parsing
111
108
# within _blit, pack up the arguments into a global data structure.
112
- args = photoimage , dataptr , offsets , bboxptr , comp_rule
109
+ args = photoimage , data , offsets , bboxptr , comp_rule
113
110
# Need a unique key to avoid thread races.
114
111
# Again, make the key a string to avoid string parsing in _blit.
115
112
argsid = str (id (args ))
0 commit comments