[wx2.8.0, wxGTK, gcc4.1.2] wxDC::Blit() and wxMask again
Kövesdi György
kgy at deverto.hu
Mon Jan 29 02:09:18 PST 2007
Hi,
I tried to put the SetMask() function call before the SelectObject() function,
so the source is:
wxMemoryDC mdc;
wxBitmap bm(100, 100);
bm.SetMask(new wxMask(bm, *wxBLUE));
mdc.SelectObject(bm);
mdc.SetBackground(*wxBLUE_BRUSH);
mdc.SetPen(wxPen(wxColour(0, 0, 0), 8));
mdc.Clear();
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));
This can be pasted into the file samples/controls/controls.cpp (at line 974 in
2.8.0, or at line 981 in 2.6.3).
Funny thing happened: the result is sometimes good, and sometimes bad with the
version 2.8.0. Starting the ./controls program the background is sometimes
blue, sometimes green, and there is a noise in very few cases. I think there
must be something uninitialized.
It does not work with the version 2.6.3 at all. (the background was always
blue).
Is the behavior of the wxMask() changed in 2.8.0 ?
Regards:
Gyorgy Kovesdi
>1) in wxMSW CVS HEAD it asserts at bm.SetMask(new wxMask(bm, *wxBLUE));
saying
>that bm is already selected in another DC - and that's true. So I've moved
this
>just after bm creation and before SelectObject() call.
>
>2) the MaskBlt() win32 API call seems to succeed and the mask passed to it
>seems valid to me so I'm not sure as why the code fails.
>I'd suggest you to rewrite it using directly win32 API and see if the problem
>persists... if you are not used to win32 API you can just copy & paste &
adapt
>the win32 API calls done by wxWidgets functions (using a debugger to step
into
>them).
>
>3) does it misbehave also on wxGTK?
>
>HTH,
>Francesco
More information about the wx-users
mailing list