99
99
# Drawing a bitmap. Note that we can easily load a PNG file
100
100
# into a surface, but I wanted to show how to convert from a
101
# wx.Bitmap here instead.
101
# wx.Bitmap here instead. This is how to do it using just cairo:
102
102
#img = cairo.ImageSurface.create_from_png(opj('bitmaps/toucan.png'))
104
# And this is how to convert a wx.Btmap to a cairo image
105
# surface. NOTE: currently on Mac there appears to be a
106
# problem using conversions of some types of images. They
107
# show up totally transparent when used. The conversion itself
108
# appears to be working okay, because converting back to
109
# wx.Bitmap or writing the image surface to a file produces
110
# the expected result. The other platforms are okay.
103
111
bmp = wx.Bitmap(opj('bitmaps/toucan.png'))
104
112
#bmp = wx.Bitmap(opj('bitmaps/splash.png'))
105
#print 'depth:', bmp.GetDepth()
106
#print 'alpha:', bmp.HasAlpha()
107
113
img = wx.lib.wxcairo.ImageSurfaceFromBitmap(bmp)
108
115
ctx.set_source_surface(img, 70, 230)
111
#bmp = wx.lib.wxcairo.BitmapFromImageSurface(img)
112
#dc.DrawBitmap(bmp, 280, 300)
118
# this is how to convert an image surface to a wx.Bitmap
119
bmp2 = wx.lib.wxcairo.BitmapFromImageSurface(img)
120
dc.DrawBitmap(bmp2, 280, 300)
115
123
def warpPath(self, ctx, tw, th, dx, dy):
142
150
#----------------------------------------------------------------------
144
152
if not haveCairo:
145
from Main import MessagePanel
153
from wx.lib.msgpanel import MessagePanel
146
154
def runTest(frame, nb, log):
147
155
win = MessagePanel(nb, 'This demo requires the Pycairo package,\n'
148
156
'or there is some other unmet dependency.',