2323 CloseEvent , KeyEvent , LocationEvent , MouseEvent , ResizeEvent )
2424from matplotlib ._pylab_helpers import Gcf
2525from . import _tkagg
26+ from ._tkagg import TK_PHOTO_COMPOSITE_OVERLAY , TK_PHOTO_COMPOSITE_SET
2627
2728
2829_log = logging .getLogger (__name__ )
@@ -51,9 +52,6 @@ def _restore_foreground_window_at_end():
5152# Initialize to a non-empty string that is not a Tcl command
5253_blit_tcl_name = "mpl_blit_" + uuid .uuid4 ().hex
5354
54- TK_PHOTO_COMPOSITE_OVERLAY = 0 # apply transparency rules pixel-wise
55- TK_PHOTO_COMPOSITE_SET = 1 # set image buffer directly
56-
5755
5856def _blit (argsid ):
5957 """
@@ -62,11 +60,11 @@ def _blit(argsid):
6260 *argsid* is a unique string identifier to fetch the correct arguments from
6361 the ``_blit_args`` dict, since arguments cannot be passed directly.
6462 """
65- photoimage , dataptr , offsets , bboxptr , comp_rule = _blit_args .pop (argsid )
63+ photoimage , data , offsets , bbox , comp_rule = _blit_args .pop (argsid )
6664 if not photoimage .tk .call ("info" , "commands" , photoimage ):
6765 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 )
7068
7169
7270def blit (photoimage , aggimage , offsets , bbox = None ):
@@ -87,7 +85,6 @@ def blit(photoimage, aggimage, offsets, bbox=None):
8785 """
8886 data = np .asarray (aggimage )
8987 height , width = data .shape [:2 ]
90- dataptr = (height , width , data .ctypes .data )
9188 if bbox is not None :
9289 (x1 , y1 ), (x2 , y2 ) = bbox .__array__ ()
9390 x1 = max (math .floor (x1 ), 0 )
@@ -109,7 +106,7 @@ def blit(photoimage, aggimage, offsets, bbox=None):
109106
110107 # tkapp.call coerces all arguments to strings, so to avoid string parsing
111108 # 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
113110 # Need a unique key to avoid thread races.
114111 # Again, make the key a string to avoid string parsing in _blit.
115112 argsid = str (id (args ))
0 commit comments