views:

491

answers:

4

Hello, I'm woundering how to make a window transparent, not cutout holes or the same transparency overall.

Well, just say I wanna slap a PNG-picture of a rose or something and have it blend nicely with stuff in behind and allow stuff behind to redraw and have their changes shine throught the transparent parts of the picture/window.

I could ( or would like to ) use something like wxWidgets or OpenGL. But rather not QT or GTK.

Thanx in advance.

A: 

See wxTopLevelWindow::SetTransparent.

If the platform supports it will set the window to be translucent.

So I guess wxWidgets can do it.

eed3si9n
I knew about that function, it sets the whole window to the same transparency. Not really what I meant.I wants to have some pixels fully transparent, some others fully opacue and many others to be somewhere in between.Like this random pic from the web (searched for "redrose.png" at google):http://www.uniqueboutiquedallas.com/images/redrose.pngit's edges is transparent and makes it blend in with whatever is behind.Look at http://www.rainlendar.net/cms/components/com_rny_gallery/simpleviewer/images/Skins-Win.png and you see how the windows are transparent on some portions.
Frank
A: 

If you are willing to do something other than C++, there may be other cross platform options like JavaFx and Adobe AIR.

eed3si9n
I personally ( Really much ) dislikes them both. So no, is the simple answer.
Frank
+2  A: 

I found out that it's actually pretty simple to throw up a transparent picture on the screen using wxW:

wxScreenDC dc;

wxBitmap bmp(wxT("test.png"), wxBITMAP_TYPE_PNG);
dc.DrawBitmap(bmp, 250, 100, true);

Now I has to find out how to handle updates and such, it has to be ( maybe partially redrawn ) when something beneath updates.

As it is right now it just redraws itself ontop of itself, making it become fully opacue in a while.

There was another version of wxScreenDC::DrawBitmap that took a window as an argument, maybe it's that one solves this?

Frank
+1  A: 

How about using shaped frames?

wxBitmap m_bmp = wxBitmap(_T("redroseonwhite.png"), wxBITMAP_TYPE_PNG);
SetSize(wxSize(m_bmp.GetWidth(), m_bmp.GetHeight()));
wxRegion region(m_bmp, *wxWHITE);
bool m_hasShape = SetShape(region);

Look *wxWidgets-2.9.0\samples\shaped* for the full example.

DitherSky
I'm just curious, doesn't the edges get jagged? ( Alias problem )Right now I feel like I've to do it completely myself, checking out how to do it on each platform I want to support ( X-server composite extension on X, whatever on windows, etc. )
Frank