[wx2.8.0, wxGTK, gcc4.1.2] wxDC::Blit() and wxMask again
Kövesdi György
kgy at deverto.hu
Mon Jan 29 05:45:33 PST 2007
I tried it, now the source is:
wxMemoryDC mdc;
wxBitmap bm(100, 100);
mdc.SelectObject(bm);
mdc.SetBackground(*wxBLUE_BRUSH);
mdc.Clear();
mdc.SelectObject(wxNullBitmap);
bm.SetMask(new wxMask(bm, *wxBLUE));
mdc.SelectObject(bm);
mdc.SetPen(wxPen(wxColour(0, 0, 0), 8));
mdc.DrawLine(5, 5, 20, 20);
wxBitmap bm2(100, 100);
wxMemoryDC dc2;
dc2.SelectObject(bm2);
dc2.SetBackground(*wxGREEN_BRUSH);
dc2.Clear();
dc2.Blit(0, 0, 100, 100, &mdc, 0, 0, wxCOPY, true);
dc2.SelectObject(wxNullBitmap);
mdc.SelectObject(wxNullBitmap);
(void)new wxStaticBitmap(panel, wxID_ANY, bm2, wxPoint(300, 120));
Now, nothing copied in the Blit() function (the picture is full green).
In my mind the mask sould be created just before the Blit() function call,
but the whole bitmap is copied in that case (without mask).
Regards
Gyorgy Kovesdi
> KG> > Yes: the bitmap contents. You must clear it before setting the mask,
> its KG> > initial content is random.
> KG> How can I do it? The SetMask() function must be called before the
> KG> SelectObject() function (at least according to the previous
> discussions),
>
> I missed it, sorry. I'm not actually sure why this should be true but if
> it is it looks like you need to select it to clear it, then unselect it,
> set mask and select again.
>
> Regards,
> VZ
More information about the wx-users
mailing list