File tree Expand file tree Collapse file tree 1 file changed +6
-5
lines changed
Expand file tree Collapse file tree 1 file changed +6
-5
lines changed Original file line number Diff line number Diff line change @@ -196,14 +196,15 @@ def get_diff_image(self):
196196 diff = buff != self ._last_buff
197197 output = np .where (diff , buff , 0 )
198198
199- buf = BytesIO ()
200- data = output .view (dtype = np .uint8 ).reshape ((* output .shape , 4 ))
201- Image .fromarray (data ).save (buf , format = "png" )
202- # store the current buffer so we can compute the next diff
199+ # Store the current buffer so we can compute the next diff.
203200 np .copyto (self ._last_buff , buff )
204201 self ._force_full = False
205202 self ._png_is_old = False
206- return buf .getvalue ()
203+
204+ data = output .view (dtype = np .uint8 ).reshape ((* output .shape , 4 ))
205+ with BytesIO () as png :
206+ Image .fromarray (data ).save (png , format = "png" )
207+ return png .getvalue ()
207208
208209 def get_renderer (self , cleared = None ):
209210 # Mirrors super.get_renderer, but caches the old one so that we can do
You can’t perform that action at this time.
0 commit comments