简体   繁体   English

透明窗口与模糊的角落

[英]Transparent window with blurred corners

I want to have a WS_POPUP window with blurred edges like this illustration: 我想要一个带有模糊边缘的WS_POPUP窗口,如下图所示:

在此输入图像描述

Any suggestions? 有什么建议么? I've been looking into layered windows but still don't know how I could achieve the full transparent pixels in the edges. 我一直在寻找分层窗口,但仍然不知道如何在边缘实现完整的透明像素。 Maybe i could put a bitmap over the complete window but how do i make the background transparent? 也许我可以在整个窗口上放置一个位图但是如何使背景透明? If I have a layered window with a bitmap, the complete bitmap becomes transparent. 如果我有一个带位图的分层窗口,则完整的位图变为透明。

You need to use a layered window (one with the WS_EX_LAYERED extended window style set) and provide a 32-bit bitmap with alpha channel using the UpdateLayeredWindow function. 您需要使用分层窗口(具有WS_EX_LAYERED扩展窗口样式集的窗口)并使用UpdateLayeredWindow函数提供带有alpha通道的32位位图。

The docs for this function are here: http://msdn.microsoft.com/en-us/library/windows/desktop/ms633556(v=vs.85).aspx 这个函数的文档在这里: http//msdn.microsoft.com/en-us/library/windows/desktop/ms633556(v = vs.85).aspx

Basically, you no longer use a standard paint loop with WM_PAINT but instead just provide a full 32-bit bitmap for the entire contents of the window. 基本上,您不再使用WM_PAINT的标准绘制循环,而只是为窗口的整个内容提供完整的32位位图。 Note that the APIs use premultiplied alpha , which means that the red, green and blue channel values in the bitmap must be premultiplied with the alpha channel value (explained here: http://msdn.microsoft.com/en-us/library/windows/desktop/dd183393(v=vs.85).aspx ). 请注意,API使用预乘alpha ,这意味着位图中的红色,绿色和蓝色通道值必须与alpha通道值预乘(在此处说明: http//msdn.microsoft.com/en-us/library/ windows / desktop / dd183393(v = vs.85).aspx )。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM