C ++中的跨平台透明窗口?

时间:2021-12-08 03:07:24

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

我想知道如何使窗户透明,而不是切口孔或整体相同的透明度。

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

好吧,只是说我要拍一张玫瑰花或其他东西的PNG图像,让它与背后的东西很好地融合,让后面的东西重绘,让它们的变化通过图片/窗口的透明部分闪耀。

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

我可以(或者想)使用像wxWidgets或OpenGL这样的东西。而不是Qt或GTK。

4 个解决方案

#1


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

我发现使用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?

还有另一个版本的wxScreenDC :: DrawBitmap以一个窗口作为参数,也许这是一个解决了这个问题?

#2


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.

查看* wxWidgets-2.9.0 \ samples \ shaped *作为完整示例。

#3


See wxTopLevelWindow::SetTransparent.

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

如果平台支持它将把窗口设置为半透明。

So I guess wxWidgets can do it.

所以我猜wxWidgets可以做到。

#4


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

如果您愿意做除C ++之外的其他事情,可能还有其他跨平台选项,如JavaFx和Adobe AIR。

#1


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

我发现使用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?

还有另一个版本的wxScreenDC :: DrawBitmap以一个窗口作为参数,也许这是一个解决了这个问题?

#2


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.

查看* wxWidgets-2.9.0 \ samples \ shaped *作为完整示例。

#3


See wxTopLevelWindow::SetTransparent.

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

如果平台支持它将把窗口设置为半透明。

So I guess wxWidgets can do it.

所以我猜wxWidgets可以做到。

#4


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

如果您愿意做除C ++之外的其他事情,可能还有其他跨平台选项,如JavaFx和Adobe AIR。