With the latest stable release of Windows 10 ( 10586
), the color of the Win32 window name changes to match the color of the chrome window.
For example, if the window color is darker, the title uses white. On the contrary.
So, since I want this behavior, I needed to get the color brightness of the chrome window.
Using this method:
public static int GetBrightness(this Color c) { return (int)Math.Sqrt( cR * cR * .241 + cG * cG * .691 + cB * cB * .068); }
And I used this other method:
public static float GetBrightness2(this Color color) { float num = ((float)color.R) / 255f; float num2 = ((float)color.G) / 255f; float num3 = ((float)color.B) / 255f; float num4 = num; float num5 = num; if (num2 > num4) num4 = num2; if (num3 > num4) num4 = num3; if (num2 < num5) num5 = num2; if (num3 < num5) num5 = num3; return ((num4 + num5) / 2f); }
So, all I had to do was check all the colors to get the threshold (first method, second method) :
White Title: 127 0,58 120 0,55 105 0,39 127 0,34 101 0,43 109 0,43 105 0,44 86 0,31 105 0,36 83 0,32 68 0,26 136 0,47 106 0,41 108 0,44 109 0,42 110 0,39 89 0,34 108 0,58 105 0,25 83 0,34 75 0,29 108 0,39 106 0,40 108 0,51 Black Title: 189 0,47 161 0,47 138 0,65 150 0,35 143 0,32 138 0,58 161 0,37 167 0,45
Only a few pieces of flowers led to a black color, and the threshold was apparently 137
.
The problem arose when I selected Automatically pick an accent color from my background
:
Automatic, Black Title: 132 0,37 Color: {
As you can see, 132 is less than 137, but it shows a black title. Therefore, my GetBrightness()
method may be different from the method that Windows uses.
So how exactly does Windows 10 determine which color the title should use?