drawing to wxBitmap with alpha channel
Stefan Csomor
csomor at advancedconcepts.ch
Thu Nov 9 04:27:35 PST 2006
Hi
> What shall be the output of the following code (paint event handler) ?
>
> wxGCDC dc(this);
>
> int w,h;
> GetClientSize(&w, &h);
>
> wxBitmap bmp = wxBitmap(w, h, 32);
> wxMemoryDC mdc;
> mdc.SelectObject(bmp);
>
> wxGCDC gcdc(mdc);
> gcdc.SetBackground(wxBrush(wxColour(0, 0, 0, 0)));
> gcdc.Clear();
> gcdc.SetPen(wxPen(wxColour(100, 100, 100, 100)));
> gcdc.DrawLine(0, h, w, 0);
>
> dc.SetBackground(*wxBLACK_BRUSH);
> dc.Clear();
> dc.SetPen(*wxRED_PEN);
> dc.DrawLine(0, 0, w, h);
> dc.Blit(0, 0, w, h, &gcdc, 0, 0, wxCOPY);
>
> Only the red line is draw. It seems that blit operation has
> no effect at all.
>
> What is wrong with this code?
nothing but the fact that this form of blitting is not (yet) supported.
You cannot yet do a blit on a wxGCDC from a wxGCDC, ie use gcdc for
blitting. Best now probably would be to get the wxBitmap back from the
gcdc and then do a DrawBitmap on the dc, this should work on msw and osx
right now. I've not yet implemented bitmaps on cairo, as OSX is on the
critical path right now, we've got more time with the other platforms...
Best,
Stefan
More information about the wx-users
mailing list