Vista/7:如何获得玻璃颜色?

发布于 2024-09-16 00:39:01 字数 4788 浏览 2 评论 0 原文

如何使用 DwmGetColorizationColor?

文档表示它返回两个值:

  • 32 -bit 0xAARRGGBB 包含用于玻璃成分的颜色,
  • 一个布尔参数,“如果颜色是不透明混合”,则为 true(无论这意味着什么

这是我喜欢的颜色,漂亮的呕吐绿色: alt text

您可以注意到颜色是绿色的,半透明的标题栏(白色背景)非常明显地显示鼻涕颜色清楚地: 在此处输入图像描述

我尝试从 Windows 获取颜色:

DwmGetColorizationColor(dwCcolorization, bIsOpaqueBlend);

并且我得到

dwColorization: 0x0D0A0F04
bIsOpaqueBlend: false

根据文档,该值的格式AARRGGBB,因此包含:

AA: 0x0D (13)
RR: 0x0A (10)
GG: 0x0F (15)
BB: 0x04 (4)

这意味着颜色为 (10, 15, 4),不透明度约为 5.1%。

但如果你真正看一下这个 RGB 值,它与我想要的鼻涕绿色相差甚远。这是

  • 不透明度为零(原始颜色)的 (10, 15, 4),以及
  • 白色/棋盘背景下不透明度为 5% 的 (10,15,4):

alt text

DwmGetColorizationColor 返回几乎完全透明的黑色,而不是石灰绿色。

那么问题是:在Windows Vista/7中如何获取玻璃颜色

我尝试使用DwmGetColorizationColor,但这效果不太好。


有同样问题的人,但有更好的闪亮图片来吸引松鼠: 替代文字

所以,归结为—— DwmGetColorizationColor 完全 无法用于尝试使用的应用程序 将当前颜色应用到 不透明表面。


我喜欢这个家伙屏幕截图比我的好得多。使用他的屏幕截图作为模板,我制作了更多火花:

alt text

替代文字

替代文字

替代文字

替代文字

alt text

对于最后两个屏幕截图,Alpha 混合芯片是真正的部分透明 PNG,与浏览器的背景混合。凉爽的! (我真是个极客)

编辑2:必须将它们排列成彩虹色。 (我真是个极客)

编辑 3:现在我当然必须添加黄色。


无文档/不受支持/脆弱的解决方法

有一个来自 DwmApi.dll 的无文档导出 在入口点 137,我们将其称为 DwmGetColorizationParameters

HRESULT GetColorizationParameters_Undocumented(out DWMCOLORIZATIONPARAMS params);

struct DWMCOLORIZATIONPARAMS
{
   public UInt32 ColorizationColor;
   public UInt32 ColorizationAfterglow;
   public UInt32 ColorizationColorBalance;
   public UInt32 ColorizationAfterglowBalance;
   public UInt32 ColorizationBlurBalance;
   public UInt32 ColorizationGlassReflectionIntensity;
   public UInt32 ColorizationOpaqueBlend;
}

我们对第一个参数感兴趣:ColorizationColor

我们还可以从注册表中读取该值:

HKEY_CURRENT_USER\Software\Microsoft\Windows\DWM
    ColorizationColor: REG_DWORD = 0x6614A600

因此,您可以选择创建应用程序兼容性问题的毒药。您可以

另请参阅


我一年多以来一直想问这个问题。我一直都知道这是不可能回答的,而让人们真正关注的唯一方法就是拥有丰富多彩的屏幕截图;开发人员被闪亮的东西所吸引。但不利的一面是,这意味着我必须投入各种精力来制作鱼饵。

How do you use DwmGetColorizationColor?

The documentation says it returns two values:

  • a 32-bit 0xAARRGGBB containing the color used for glass composition
  • a boolean parameter that is true "if the color is an opaque blend" (whatever that means)

Here's a color that i like, a nice puke green:
alt text

You can notice the color is greeny, and the translucent title bar (against a white background) shows the snot color very clearly:
enter image description here

i try to get the color from Windows:

DwmGetColorizationColor(dwCcolorization, bIsOpaqueBlend);

And i get

dwColorization: 0x0D0A0F04
bIsOpaqueBlend: false

According to the documentation this value is of the format AARRGGBB, and so contains:

AA: 0x0D (13)
RR: 0x0A (10)
GG: 0x0F (15)
BB: 0x04 (4)

This supposedly means that the color is (10, 15, 4), with an opacity of ~5.1%.

But if you actually look at this RGB value, it's nowhere near my desired snot green. Here is

  • (10, 15, 4) with zero opacity (the original color), and
  • (10,15,4) with 5% opacity against a white/checkerboard background:

alt text

Rather than being Lime green, DwmGetColorizationColor returns an almost fully transparent black.

So the question is: How to get glass color in Windows Vista/7?

i tried using DwmGetColorizationColor, but that doesn't work very well.


A person with same problem, but a nicer shiny picture to attract you squirrels:
alt text

So, it boils down to –
DwmGetColorizationColor is completely
unusable for applications attempting
to apply the current color onto an
opaque surface.


i love this guy's screenshots much better than mine. Using his screenshots as a template, i made up a few more sparklies:

alt text

alt text

alt text

alt text

alt text

alt text

For the last two screenshots, the alpha blended chip is a true partially transparent PNG, blending to your browser's background. Cool! (i'm such a geek)

Edit 2: Had to arrange them in rainbow color. (i'm such a geek)

Edit 3: Well now i of course have to add Yellow.


Undocumented/Unsupported/Fragile Workarounds

There is an undocumented export from DwmApi.dll at entry point 137, which we'll call DwmGetColorizationParameters:

HRESULT GetColorizationParameters_Undocumented(out DWMCOLORIZATIONPARAMS params);

struct DWMCOLORIZATIONPARAMS
{
   public UInt32 ColorizationColor;
   public UInt32 ColorizationAfterglow;
   public UInt32 ColorizationColorBalance;
   public UInt32 ColorizationAfterglowBalance;
   public UInt32 ColorizationBlurBalance;
   public UInt32 ColorizationGlassReflectionIntensity;
   public UInt32 ColorizationOpaqueBlend;
}

We're interested in the first parameter: ColorizationColor.

We can also read the value out of the registry:

HKEY_CURRENT_USER\Software\Microsoft\Windows\DWM
    ColorizationColor: REG_DWORD = 0x6614A600

So you pick your poison of creating appcompat issues. You can

See also


i've been wanting to ask this question for over a year now. i always knew that it's impossible to answer, and that the only way to get anyone to actually pay attention is to have colorful screenshots; developers are attracted to shiny things. But on the downside it means i had to put all kinds of work into making the lures.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

来世叙缘 2024-09-23 00:39:01

着色颜色!=所选的基色。我知道这是误导。

但我很困惑。您借用的图片来自我题为“检索 Aero Glass 基色以进行不透明表面渲染”。这不是你想做的吗?我还在帖子中指出了存储所有颜色信息的注册表位置 (HKEY_CURRENT_USER\Software\Microsoft\Windows\DWM) 以供检索之用。

已编辑 8/26

DwmGetColorizationColor (dwmapi.dll) 返回“着色颜色”,它是各种颜色(包括您选择的基色)和着色器逻辑的混合,以实现整体玻璃效果。

您需要/想要的所有颜色信息都可以在上面提到的注册表项中找到。基色、混合中使用的颜色以及最终的着色颜色都在那里。

(上面的键存在于 Windows Vista 及更高版本中。)

Colorization color != the base color chosen. It's misleading, I know.

But I'm confused. The image you borrowed was from my post entitled "Retrieving Aero Glass base color for opaque surface rendering". Is this not what you want to do? I also indicated in the post the registry location in which all the color information is stored (HKEY_CURRENT_USER\Software\Microsoft\Windows\DWM) for retrieval purposes.

Edited 8/26

DwmGetColorizationColor (dwmapi.dll) returns the "colorization color", which is a blend of various colors (incl. your selected base color) and shader logic to achieve the overall glass effect.

All the color information you need/want can be found in the registry key noted above. The base color, the colors used in blending, and the resulting colorization color are all there.

(The key above is present on Windows Vista and above.)

简单 2024-09-23 00:39:01

我相信我已经解决了 Aero Color。 ColorizationColor 给出的颜色实际上是 AARRGGBB,但它根本没有按照您想象的方式使用。为了解决最终的颜色,您还需要获取颜色强度,如下所示: http://www.codeproject.com/Articles/610909/Changing-Windows-Aero-Color

第一步是解析 AARRGGBB。然后将生成的 RGB 转换为 HSV。纯色相加上全亮度饱和度是基色。现在将值作为 Alpha 的灰度叠加在纯色相和饱和度之上,以获得 Aero 颜色。然后将该颜色叠加在帧颜色上:强度为 rgb(235, 235, 235),以获得最终的 Composite Aero 颜色结果。

最后,我还提供了一个示例,说明如何提取与 Aero 框架颜色相匹配的可用工具栏颜色,但始终适用于黑色文本和其他基本 Aero 功能。这是通过将强度限制为 35% 来实现的。

这是数学:

  function dwmToRgb() { 
    // Input Values
    var colorizationColor = "a84f1b1b"; // dwmcolor.clrColor = ColorizationColor
    var colorizationColorBalance = 60; // dwmcolor.nIntensity = ColorizationColorBalance 
    var F = 235; // Frame base grayscale color when Transparency is disabled

    // Parse the input values    
    var A = Math.round(parseInt(colorizationColor.substr(0,2),16)/2.55)/100;
    var R1 = parseInt(colorizationColor.substr(2,2), 16);
    var G1 = parseInt(colorizationColor.substr(4,2), 16);
    var B1 = parseInt(colorizationColor.substr(6,2), 16);
    var I = colorizationColorBalance/100;

    // Solve for HSV Value and pure Hue+Sat
    var V = Math.max(R1, G1, B1);
    var R2 = R1*255/V;
    var G2 = G1*255/V;
    var B2 = B1*255/V;

    // Aero Frame Pure Hue: Overlay Value @ Alpha over pure Hue+Sat
    var R3 = Math.round(V+(R2-V)-((R2-V)*A));
    var G3 = Math.round(V+(G2-V)-((G2-V)*A));
    var B3 = Math.round(V+(B2-V)-((B2-V)*A)); 
    var hexRGB3 = "#" + ((1 << 24) + (R3 << 16) + (G3 << 8) + B3).toString(16).slice(1);

    // Aero Frame Composite Color: Overlay RGB3 @ Intensity over Frame base color        
    var R4 = Math.round(R3+(F-R3)-((F-R3)*I));
    var G4 = Math.round(G3+(F-G3)-((F-G3)*I));
    var B4 = Math.round(B3+(F-B3)-((F-B3)*I));   
    var hexRGB4 = "#" + ((1 << 24) + (R4 << 16) + (G4 << 8) + B4).toString(16).slice(1);

    // Aero Toolbar Color: Overlay RGB3 @ max 35% Intensity over Frame base color   
    if (I > 0.35) { I5 = 0.35;} else { I5 = I;}
    var R5 = Math.round(R3+(F-R3)-((F-R3)*I5));
    var G5 = Math.round(G3+(F-G3)-((F-G3)*I5));
    var B5 = Math.round(B3+(F-B3)-((F-B3)*I5));   
    var hexRGB5 = "#" + ((1 << 24) + (R5 << 16) + (G5 << 8) + B5).toString(16).slice(1);

I believe I have solved the Aero Color. The color given by ColorizationColor is in fact AARRGGBB but it is not being used in the way that you think at all. And in order to solve the final color, you also need to get the Color Intensity as shown here: http://www.codeproject.com/Articles/610909/Changing-Windows-Aero-Color

First step is to parse AARRGGBB. Then take the resulting RGB and convert to HSV. The pure Hue plus Saturation at full brightness is the base color. Now overlay Value as a grayscale at Alpha over top of pure Hue and Saturation to get the Aero color. Then overlay that color over the frame color: rgb(235, 235, 235) at Intensity to get the final Composite Aero color result.

Lastly, I've also provided an example of how to extract a useable toolbar color that matches the Aero frame color, but will always work with black text and other basic Aero features. This is accomplished by limiting Intensity to 35%.

Here is the math:

  function dwmToRgb() { 
    // Input Values
    var colorizationColor = "a84f1b1b"; // dwmcolor.clrColor = ColorizationColor
    var colorizationColorBalance = 60; // dwmcolor.nIntensity = ColorizationColorBalance 
    var F = 235; // Frame base grayscale color when Transparency is disabled

    // Parse the input values    
    var A = Math.round(parseInt(colorizationColor.substr(0,2),16)/2.55)/100;
    var R1 = parseInt(colorizationColor.substr(2,2), 16);
    var G1 = parseInt(colorizationColor.substr(4,2), 16);
    var B1 = parseInt(colorizationColor.substr(6,2), 16);
    var I = colorizationColorBalance/100;

    // Solve for HSV Value and pure Hue+Sat
    var V = Math.max(R1, G1, B1);
    var R2 = R1*255/V;
    var G2 = G1*255/V;
    var B2 = B1*255/V;

    // Aero Frame Pure Hue: Overlay Value @ Alpha over pure Hue+Sat
    var R3 = Math.round(V+(R2-V)-((R2-V)*A));
    var G3 = Math.round(V+(G2-V)-((G2-V)*A));
    var B3 = Math.round(V+(B2-V)-((B2-V)*A)); 
    var hexRGB3 = "#" + ((1 << 24) + (R3 << 16) + (G3 << 8) + B3).toString(16).slice(1);

    // Aero Frame Composite Color: Overlay RGB3 @ Intensity over Frame base color        
    var R4 = Math.round(R3+(F-R3)-((F-R3)*I));
    var G4 = Math.round(G3+(F-G3)-((F-G3)*I));
    var B4 = Math.round(B3+(F-B3)-((F-B3)*I));   
    var hexRGB4 = "#" + ((1 << 24) + (R4 << 16) + (G4 << 8) + B4).toString(16).slice(1);

    // Aero Toolbar Color: Overlay RGB3 @ max 35% Intensity over Frame base color   
    if (I > 0.35) { I5 = 0.35;} else { I5 = I;}
    var R5 = Math.round(R3+(F-R3)-((F-R3)*I5));
    var G5 = Math.round(G3+(F-G3)-((F-G3)*I5));
    var B5 = Math.round(B3+(F-B3)-((F-B3)*I5));   
    var hexRGB5 = "#" + ((1 << 24) + (R5 << 16) + (G5 << 8) + B5).toString(16).slice(1);
鼻尖触碰 2024-09-23 00:39:01

您觉得 A0F040 怎么样?


OP编辑:这就是0xA0F040对我来说的样子:

alt text

How does A0F040 look to you?


OP Edit: This is how 0xA0F040 looks to me:

alt text

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文