![]() |
Aero color
I want to get Aero color:
I wrote this:
Delphi-Quellcode:
It working, but because uses undocumented function (I got pointer, because I know offset), I tried again with documented function:
var
Params: TColorizationParams; begin if IsAeroEnabled then begin if Assigned(DwmGetColorizationParameters) then begin ZeroMemory(@Params, SizeOf(Params)); DwmGetColorizationParameters(Params); Result := RGB(GetBValue(Params.clrColor), GetGValue(Params.clrColor), GetRValue(Params.clrColor)); end; end; end;
Delphi-Quellcode:
Above formula I got from [DP]http://www.delphipraxis.net/147316-vista-win7-aero-farbe-auslesen.html[/DP]. It's not valid of course (color processing inside).
var
pcrColorization: DWORD; pfOpaqueBlend: BOOL; A, R, G, B: Integer; begin if IsAeroEnabled then begin if DwmGetColorizationColor(pcrColorization,pfOpaqueBlend) = S_OK then begin A := (pcrColorization and $FF000000) shr 24; R := (pcrColorization and $FF0000) shr 16; G := (pcrColorization and $FF00) shr 8; B := (pcrColorization and $FF); R := Min(255, Max(0, R + (255 - A - 40))); G := Min(255, Max(0, G + (255 - A - 40))); B := Min(255, Max(0, B + (255 - A - 40))); Result := RGB(R, G, B); end; end; end; AARRGGBB, so I tried also:
Delphi-Quellcode:
but color too dark. How to decode this color?
R := (pcrColorization shr 16) and $FF;
G := (pcrColorization shr 8) and $FF; B := pcrColorization and $FF; |
AW: Aero color
I think the DWM uses the premultiplied alpha format internally (I found
![]() Thus, if you do not take this into account, your colors will appear too dark if A<1.0. Fortunately, converting premultiplied alpha back to “normal” colors (although, after reading the above blog post, you will understand that premultiplied alpha actually makes much more sense ;)) is as simple as dividing each component by A. The only catch is that you will naturally get an error if A=0 because the color is undetermined in that case. |
AW: Aero color
In addition to that: (32bit) colors are commonly stored in ABGR order, much less often in ARGB as you used it. Thus, you might just only have swapped the R and B channel.
|
Re: Aero color
Delphi-Quellcode:
Similar, but a bit too dark :(
A := (pcrColorization shr 24) and $FF;
R := (pcrColorization shr 16) and $FF; G := (pcrColorization shr 8) and $FF; B := pcrColorization and $FF; if A <> 0 then begin R := Clamp(R + (R div A), 0, 255); G := Clamp(G + (G div A), 0, 255); B := Clamp(B + (B div A), 0, 255); end; |
AW: Aero color
Why are you adding the original value?
Try this:
Delphi-Quellcode:
[edit]
if A <> 0 then
begin R := Clamp(255*R div A, 0, 255); G := Clamp(255*G div A, 0, 255); B := Clamp(255*B div A, 0, 255); end; Btw @Medium: The order used by this function is in fact ARGB: ![]() [/edit] |
AW: Aero color
How odd, especially because it's used in context with D3D. I stand corrected though :)
|
Re: Aero color
Hm, color also is not valid.
|
Alle Zeitangaben in WEZ +1. Es ist jetzt 06:43 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz