|
96 | 96 |
|
97 | 97 |
|
98 | 98 | import sys, os, os.path, math, StringIO, weakref, warnings |
| 99 | +import numpy as npy |
99 | 100 |
|
100 | 101 | # Debugging settings here... |
101 | 102 | # 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): |
333 | 334 | gfx_ctx.StrokePath(wxpath) |
334 | 335 | gc.unselect() |
335 | 336 |
|
| 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 | + |
336 | 354 | def draw_text(self, gc, x, y, s, prop, angle, ismath): |
337 | 355 | """ |
338 | 356 | Render the matplotlib.text.Text instance |
@@ -482,15 +500,15 @@ def select(self): |
482 | 500 | """ |
483 | 501 |
|
484 | 502 | if sys.platform=='win32': |
485 | | - self.SelectObject(self.bitmap) |
| 503 | + self.dc.SelectObject(self.bitmap) |
486 | 504 | self.IsSelected = True |
487 | 505 |
|
488 | 506 | def unselect(self): |
489 | 507 | """ |
490 | 508 | Select a Null bitmasp into this wxDC instance |
491 | 509 | """ |
492 | 510 | if sys.platform=='win32': |
493 | | - self.SelectObject(wx.NullBitmap) |
| 511 | + self.dc.SelectObject(wx.NullBitmap) |
494 | 512 | self.IsSelected = False |
495 | 513 |
|
496 | 514 | def set_foreground(self, fg, isRGB=None): |
|
0 commit comments