drawing on wxDC with transparency
Christopher Bruno
cbruno.linux at gmail.com
Fri May 9 11:08:12 PDT 2008
>> This is a no-go for me as I can not assume that a color won't be used
when drawing
Well then draw your picture to another buffer and then use
wxImage::FindFirstUnsedColour. Set the mask of a new bitmap to be drawn to
the colour this returns, and then blit over your drawing from the first
buffer.
On Fri, May 9, 2008 at 12:28 PM, personaje <personaje at gmail.com> wrote:
> On Thu, May 8, 2008 at 12:34 PM, Christopher Bruno
> <cbruno.linux at gmail.com> wrote:
> > I solved this problem by using a wxMemoryDC to draw to a bitmap. First I
> set
> > the background colour to some odd colour that I will not use in my
> drawing
> > (the mask). Then I drew my picture with memDC to the bitmap, and then
> > converted the bitmap to a wxImage. I then wrote a function called
> > SetColourToAlpha(wxImage &, const wxColour & , int) that went through a=
nd
> > checked the colour at each pixel in the image. If the pixel RGB value
> > equaled the same as the mask colour, I set the alpha value to the int
> passed
> > at that pixel. Slow (w*h time), but it works. This will also help you g=
et
> > translucency if you alpha value > 0. Remember to call InitAlpha() on t=
he
> > wximage or it wont work
> >
> > Your problem is that you set the alpha value for the image before you
> draw,
> > and never change it, so the parts you draw still cant be seen (they have
> > alpha 0). Set the alpha value after to draw to the parts you want
> > transparent. Hope that helps.
>
> .
>
> The problem must lie in that wxMemoryDC does not propagate to the
> alpha of the asociated bitmap.
>
> regards
> _______________________________________________
> wx-users mailing list
> wx-users at lists.wxwidgets.org
> http://lists.wxwidgets.org/mailman/listinfo/wx-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.wxwidgets.org/pipermail/wx-users/attachments/20080509/346=
3e179/attachment.htm
More information about the wx-users
mailing list