On 11/9/11 6:36 AM, GAndrewStone wrote:
> Hi all,
>
> It seems like there should be an easy answer to this, but I've
> searched for about a day and can't find one. I want to paint inside a
> bitmap preserving the alpha channel so that later I can composite this
> bitmap onto another surface with Alpha blending. I need to use cairo
> (for rsvg) and the normal GraphicsContext and/or GCDC but I can't
> figure out how to get a handle to these without going through a
> standard DC (wxMemoryDC). For example, to get the cairo handle, I
> think I need to use: wx.lib.wxcairo.ContextFromDC(). For
> GraphicsContext it looks like there is a "Create(dc)" function
>
> But as soon as I select the bitmap into the DC
> (dc.SelectObject(mybitmap)), it turns off the Alpha channel in the
> bitmap!
I don't think that wx.MemoryDC should be doing that. Please create a
small runnable sample that shows the problem and I'll try to dig a
little deeper into it. Also, which platform and version are you using?
http://wiki.wxpython.org/MakingSampleAppsIf you want to use just Cairo then you can create a Cairo ImageSurface
from the wx.Bitmap with wx.lib.wxcairo.ImageSurfaceFromBitmap. You can
then use the cairo module to create a context that draws to that
surface. There is also a function to convert the surface back to a
wx.Bitmap.
In 2.9.2.4 you should be able to make a wx.GrpahicsContext from that
cairo context on Windows and GTK. It will be possible on Mac too but
the code for dynamically loading the cairo lib hasn't been done there yet.
In 2.9.3 it will be possible to make a wx.GraphicsContext that draws to
a wx.Image, (so no wx.MemoryDC required) although I haven't tried it yet
so I don't know if there are any limitations.
--
Robin Dunn
Software Craftsman
http://wxPython.org--
To unsubscribe, send email to
[hidden email]
or visit
http://groups.google.com/group/wxPython-users?hl=en