本文整理匯總了Python中wx.BitmapFromBufferRGBA方法的典型用法代碼示例。如果您正苦於以下問題:Python wx.BitmapFromBufferRGBA方法的具體用法?Python wx.BitmapFromBufferRGBA怎麽用?Python wx.BitmapFromBufferRGBA使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類wx
的用法示例。
在下文中一共展示了wx.BitmapFromBufferRGBA方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: draw_image
# 需要導入模塊: import wx [as 別名]
# 或者: from wx import BitmapFromBufferRGBA [as 別名]
def draw_image(self, gc, x, y, im):
bbox = gc.get_clip_rectangle()
if bbox != None:
l,b,w,h = bbox.bounds
else:
l=0
b=0,
w=self.width
h=self.height
rows, cols, image_str = im.as_rgba_str()
image_array = np.fromstring(image_str, np.uint8)
image_array.shape = rows, cols, 4
bitmap = wx.BitmapFromBufferRGBA(cols,rows,image_array)
gc = self.get_gc()
gc.select()
gc.gfx_ctx.DrawBitmap(bitmap,int(l),int(self.height-b),int(w),int(-h))
gc.unselect()
示例2: _convert_agg_to_wx_bitmap
# 需要導入模塊: import wx [as 別名]
# 或者: from wx import BitmapFromBufferRGBA [as 別名]
def _convert_agg_to_wx_bitmap(agg, bbox):
"""
Convert the region of the agg buffer bounded by bbox to a wx.Bitmap. If
bbox is None, the entire buffer is converted.
Note: agg must be a backend_agg.RendererAgg instance.
"""
if bbox is None:
# agg => rgba buffer -> bitmap
return wx.BitmapFromBufferRGBA(int(agg.width), int(agg.height),
agg.buffer_rgba())
else:
# agg => rgba buffer -> bitmap => clipped bitmap
return _WX28_clipped_agg_as_bitmap(agg, bbox)
示例3: _WX28_clipped_agg_as_bitmap
# 需要導入模塊: import wx [as 別名]
# 或者: from wx import BitmapFromBufferRGBA [as 別名]
def _WX28_clipped_agg_as_bitmap(agg, bbox):
"""
Convert the region of a the agg buffer bounded by bbox to a wx.Bitmap.
Note: agg must be a backend_agg.RendererAgg instance.
"""
l, b, width, height = bbox.bounds
r = l + width
t = b + height
srcBmp = wx.BitmapFromBufferRGBA(int(agg.width), int(agg.height),
agg.buffer_rgba())
srcDC = wx.MemoryDC()
srcDC.SelectObject(srcBmp)
destBmp = wx.EmptyBitmap(int(width), int(height))
destDC = wx.MemoryDC()
destDC.SelectObject(destBmp)
destDC.BeginDrawing()
x = int(l)
y = int(int(agg.height) - t)
destDC.Blit(0, 0, int(width), int(height), srcDC, x, y)
destDC.EndDrawing()
srcDC.SelectObject(wx.NullBitmap)
destDC.SelectObject(wx.NullBitmap)
return destBmp
示例4: bitmapFromBufferRGBA
# 需要導入模塊: import wx [as 別名]
# 或者: from wx import BitmapFromBufferRGBA [as 別名]
def bitmapFromBufferRGBA(im, rgba):
if isLatestVersion:
return wx.Bitmap.FromBufferRGBA(im.size[0], im.size[1], rgba)
else:
return wx.BitmapFromBufferRGBA(im.size[0], im.size[1], rgba)
示例5: CreateBitmapOnTopOfIcon
# 需要導入模塊: import wx [as 別名]
# 或者: from wx import BitmapFromBufferRGBA [as 別名]
def CreateBitmapOnTopOfIcon(foregroundIcon, backgroundIcon, size=(12, 12)):
small = foregroundIcon.pil.resize(size, Image.BICUBIC)
pil = backgroundIcon.pil.copy()
pil.paste(small, (16 - size[0], 16 - size[1]), small)
return wx.BitmapFromBufferRGBA(pil.size[0], pil.size[1], str(pil.tobytes()))
示例6: PilToBitmap
# 需要導入模塊: import wx [as 別名]
# 或者: from wx import BitmapFromBufferRGBA [as 別名]
def PilToBitmap(pil):
"""
Convert a PIL image to a wx.Bitmap (with alpha channel support).
"""
return wx.BitmapFromBufferRGBA(pil.size[0], pil.size[1], str(pil.tobytes()))
# setup some commonly used icons