views:

173

answers:

3

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: alt text

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

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.

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.

A: 

How does A0F040 look to you?


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

alt text

Mchl
Very far-fetched. But surprisingly close.
Andreas Rejbrand
I'm just guessing (implementing the old rule of multibyte value processing: 'if it doesn't make sense, change the byte order'). I tested it for the other two colors you posted, and the results are not that good anymore. Probably a random chance.
Mchl
You didn't change the byte order; you changed the nibble order. (And that's why I found it so far-fetched.)
Andreas Rejbrand
Yeah, i saw what he did; and i would have been terrified if that's what Microsoft was doing
Ian Boyd
Yeah... stretched the rule a bit :PAnyway, I noticed that 0A0f04 is indeed a very dark green, but green nevertheless... The two other colors also seem to be in matching hue, but darker. Maybe the alpha channel should be applied somehow to these values, to get original value?
Mchl
+1  A: 

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

Rafael Rivera
It *is* what i want to do. But like you, i would like to avoid relying on undocumented functions or registry keys. i am hoping someone can decipher what `DwmGetColorizationColor` returns. Or explain how to turn it into something related to what the user picked.
Ian Boyd
i mean, if it's a completely meaningless value: then they might as well have returned a `HANDLE`, or some other opaque value. But it *was* documented as "`AARRGGBB`" - so that must mean *something*.
Ian Boyd
The documentation also says it's a GDI+ color value. It is common in GDI+, when it mixes with native API calls, to use pre-multiplied alpha. But when i divide by the alpha it doesn't work out quite right. Sometimes the `aa` value is lower than any `rr`, `gg`, or `bb`. i've also noticed that you'll never get an alpha lower than 0x0d (13), or higher than 0xd9 (217). Perhaps it's range compressed, like the UIRibbon uses.
Ian Boyd
On the positive side, though, relying on registry keys containing visual preferences is seldom as potentially fatal as many other examples of using undocumented behaviour, which literally can crash your application (or even explorer.exe). Here you can safely determine if the registry key exists or not, and if not, you can fail gracefully (but you will probably almost never do this on a Vista/7 system). And the very worst thing that can happen, is that a colour value gets wrong. So I think that I could live with the registry approach.
Andreas Rejbrand
@Andreas Granted, i could come up with unsupported workarounds. But i was hoping someone who knows something about DWM would stumble across this question and have the actual answer.
Ian Boyd
I added a clarifying note about this. I'm still unsure what more you need... all the color information is in the registry.
Rafael Rivera
When the registry information is removed, all that will remain is the documented API.
Ian Boyd
The registry is the central store for this information. I wouldn't expect it to go away any time this decade.
Rafael Rivera
Relying on undocumented behavior is a sin; Raymond Chen will have a fit. (http://blogs.msdn.com/b/oldnewthing/archive/2003/12/24/45779.aspx)
Ian Boyd
Microsoft could overhaul the entire interface but history shows Microsoft is lethargically slow to make breaking changes. And it's unlikely this mystery application of yours would apply to later OSes (might not even have glass).
Rafael Rivera
@Rafael Rivera It's a chicken-and-the-egg problem. Microsoft cannot change their internal implementation details, because poorly written programs depends on the implementation details. So then Microsoft has to create compatibility shims for these poorly designed programs. People argue that Microsoft should just go ahead and break apps that break the rules; but Microsoft can't do that, because then "Windows 8 broke my app", rather than the accurate "my app was always broken, and it's amazing it ever worked." http://blogs.msdn.com/b/oldnewthing/archive/2003/12/24/45779.aspx
Ian Boyd
A: 

Have you tried DwmGetColorizationParameters, and blend/work from that?

Lazlo
This suffers from the problem as doing what Rafael Rivera is doing: `DwmGetColorizatoinParameters` is undocumented i.e. i cannot depend on it being there in any future version of Windows - nor can i guarantee that its return values will always mean the same thing.
Ian Boyd
I think that a new Windows OS release should always be an indicator to revisit your code anyway.
Lazlo