|
Prev: svg example
Next: wxList problem
From: "Steven Van Ingelgem" on 22 Mar 2008 16:06 system: VS2005/trunk/XP Hi, How can I draw on a bitmap in such a way that I get a bitmap with a transparent background? What I do at the moment is: dc.SetBackground( *wxTRANSPARENT_BRUSH ); dc.SetBackgroundMode(wxTRANSPARENT); dc.SetBrush( *wxTRANSPARENT_BRUSH ); dc.Clear(); & than dc.SetTextForeground to set the colour of my text... But still it keeps on giving me a black background. I think it's because in dc.cpp (1650), SetBkColor receives the wxTRANSPARENTBRUSH, which is equal to 0x02 00 00 00 (thus wxBlack). Now SetBkColor expects CLR_NONE to set the background really transparent, which is 0xFF FF FF FF (at least on windows that is). Could someone tell me if I'm wrong here and/or what I should do to correct it? Thanks! _______________________________________________ wx-users mailing list wx-users(a)lists.wxwidgets.org http://lists.wxwidgets.org/mailman/listinfo/wx-users
From: "Steven Van Ingelgem" on 22 Mar 2008 16:28 Proof of concept: Index: minimal.cpp =================================================================== --- minimal.cpp (revision 52691) +++ minimal.cpp (working copy) @@ -148,6 +148,18 @@ // set the frame icon SetIcon(wxICON(sample)); + + wxInitAllImageHandlers(); + + wxBitmap bmp(100,100); + wxMemoryDC dc(bmp); + dc.SetBackground( *wxTRANSPARENT_BRUSH ); + dc.Clear(); + dc.SetTextForeground( *wxRED ); + dc.DrawText( "This is a BUG!", 0, 0 ); + dc.SelectObject( wxNullBitmap ); + bmp.SaveFile( "/tmp/Testing.png", wxBITMAP_TYPE_PNG ); + #if wxUSE_MENUS // create a menu bar wxMenu *fileMenu = new wxMenu; Behaviour: This will create a black bitmap with red text. Expected: A transparent image with red text. Greetings On 22/03/2008, Steven Van Ingelgem <steven(a)vaningelgem.be> wrote: > system: VS2005/trunk/XP > > > Hi, > > > How can I draw on a bitmap in such a way that I get a bitmap with a > transparent background? > > > What I do at the moment is: > > dc.SetBackground( *wxTRANSPARENT_BRUSH ); > dc.SetBackgroundMode(wxTRANSPARENT); > dc.SetBrush( *wxTRANSPARENT_BRUSH ); > dc.Clear(); > > & than dc.SetTextForeground to set the colour of my text... But still > it keeps on giving me a black background. > > I think it's because in dc.cpp (1650), SetBkColor receives the > wxTRANSPARENTBRUSH, which is equal to 0x02 00 00 00 (thus wxBlack). > Now SetBkColor expects CLR_NONE to set the background really > transparent, which is 0xFF FF FF FF (at least on windows that is). > > > Could someone tell me if I'm wrong here and/or what I should do to correct it? > > > Thanks! > _______________________________________________ wx-users mailing list wx-users(a)lists.wxwidgets.org http://lists.wxwidgets.org/mailman/listinfo/wx-users
|
Pages: 1 Prev: svg example Next: wxList problem |