Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f2646dc

Browse files
committed
Applied Lee's backend wx patch
svn path=/trunk/matplotlib/; revision=6284
1 parent 55ac6dd commit f2646dc

1 file changed

Lines changed: 20 additions & 2 deletions

File tree

lib/matplotlib/backends/backend_wx.py

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@
9696

9797

9898
import sys, os, os.path, math, StringIO, weakref, warnings
99+
import numpy as npy
99100

100101
# Debugging settings here...
101102
# Debug level set here. If the debug level is less than 5, information
@@ -333,6 +334,23 @@ def draw_path(self, gc, path, transform, rgbFace=None):
333334
gfx_ctx.StrokePath(wxpath)
334335
gc.unselect()
335336

337+
def draw_image(self, x, y, im, bbox, clippath=None, clippath_trans=None):
338+
if bbox != None:
339+
l,b,w,h = bbox.bounds
340+
else:
341+
l=0
342+
b=0,
343+
w=self.width
344+
h=self.height
345+
rows, cols, image_str = im.as_rgba_str()
346+
image_array = npy.fromstring(image_str, npy.uint8)
347+
image_array.shape = rows, cols, 4
348+
bitmap = wx.BitmapFromBufferRGBA(cols,rows,image_array)
349+
gc = self.get_gc()
350+
gc.select()
351+
gc.gfx_ctx.DrawBitmap(bitmap,int(l),int(b),int(w),int(h))
352+
gc.unselect()
353+
336354
def draw_text(self, gc, x, y, s, prop, angle, ismath):
337355
"""
338356
Render the matplotlib.text.Text instance
@@ -482,15 +500,15 @@ def select(self):
482500
"""
483501

484502
if sys.platform=='win32':
485-
self.SelectObject(self.bitmap)
503+
self.dc.SelectObject(self.bitmap)
486504
self.IsSelected = True
487505

488506
def unselect(self):
489507
"""
490508
Select a Null bitmasp into this wxDC instance
491509
"""
492510
if sys.platform=='win32':
493-
self.SelectObject(wx.NullBitmap)
511+
self.dc.SelectObject(wx.NullBitmap)
494512
self.IsSelected = False
495513

496514
def set_foreground(self, fg, isRGB=None):

0 commit comments

Comments
 (0)