I wish to create wxBitmaps with transparency, based on transparent bitmaps (PNG's with alpha channel) and drawings (using wxDC functions).
The idea is to pre-bufferize some long drawings into a bitmap that I will Blit() or DrawBitmap() in wxEVT_PAINT events.
I tried it on MacOS with success:
Code: Select all
wxBitmap buf(100, 50); buf.UseAlpha(); wxMemoryDC *memDC = new wxMemoryDC(buf); memDC->SetBackground(*wxTRANSPARENT_BRUSH); memDC->Clear(); delete memDC; memDC = new wxMemoryDC(buf); // draw a red rectangle memDC->SetBrush(*wxRED_BRUSH); memDC->SetPen(*wxTRANSPARENT_PEN); memDC->DrawRectangle(10, 10, 30, 30); // draw the same rectangle from a file memDC->DrawBitmap(file_, 50, 00, true); delete memDC; buf.SaveFile(_("result.png"), wxBITMAP_TYPE_PNG);
But with wxGTK and wxMSW, the result is not correct :
- in wxGTK, the background is black
- in wxMSW, all the bitmap is transparent.
What can I do ?
I tried to ask this question some days ago, but I reformulate it to be more clear.