def updateBitmap(self): scale = self.scale * self.imageplugin.scale x, y = self.imageplugin.getXY(*self.rect.position) try: b = numpyimage.numpy2wxBitmap( self.imageplugin.array, int(round(x * scale - self.rect.width / 2.0)) + self.border, int(round(y * scale - self.rect.width / 2.0)) + self.border, self.rect.width - 2 * self.border, self.rect.height - 2 * self.border, self.imageplugin.array.shape[1] * scale, self.imageplugin.array.shape[0] * scale, self.imageplugin.valuerange) except (AttributeError, ValueError): self.bitmap = None return bitmap = wx.EmptyBitmap(*self.rect.size) dc = wx.MemoryDC() dc.SelectObject(bitmap) dc.SetPen(self.pen) dc.SetBrush(self.brush) dc.DrawRectangle(0, 0, self.rect.width, self.rect.height) sourcedc = wx.MemoryDC() sourcedc.SelectObject(b) dc.Blit(self.border, self.border, self.rect.width - 2 * self.border, self.rect.height - 2 * self.border, sourcedc, 0, 0) sourcedc.SelectObject(wx.NullBitmap) dc.SelectObject(wx.NullBitmap) image = bitmap.ConvertToImage() image.InitAlpha() size = self.rect.width * self.rect.height image.SetAlphaData(chr(self.alpha) * size) self.bitmap = image.ConvertToBitmap()
def updateBitmap(self): width, height = self.GetSize() types = [type(i) for i in self.fromrange] arraytype = None for t in types: if issubclass(t, float) or issubclass(t, numpy.floating): arraytype = numpy.float break if arraytype is None: for t in types: if t is int or t is long or issubclass(t, numpy.integer): arraytype = numpy.int break if arraytype is None: raise TypeError array = numpy.arange(width, dtype=numpy.float) array.shape = (1, width) array *= float(self.extrema[1] - self.extrema[0]) / (width - 1) array += self.extrema[0] array = array.astype(arraytype) array = array.repeat(height) array.shape = height, -1 bitmap = numpyimage.numpy2wxBitmap(array, fromrange=self.fromrange) self.SetBitmap(bitmap)
def draw(self, dc, region): regioniterator = wx.RegionIterator(region) while (regioniterator): r = regioniterator.GetRect() bitmap = numpyimage.numpy2wxBitmap(self.array, r.x - self.rect.x, r.y - self.rect.y, r.width, r.height, self.rect.width, self.rect.height, self.valuerange) sourcedc = wx.MemoryDC() sourcedc.SelectObject(bitmap) dc.Blit(r.x, r.y, r.width, r.height, sourcedc, 0, 0) sourcedc.SelectObject(wx.NullBitmap) regioniterator.Next()