Vista/7: How to get glass color?

浪尽此生 提交于 2019-11-26 15:52:15
Rafael Rivera

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.)

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);
Mchl

How does A0F040 look to you?


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!