{
}
#endif
+ // FindColorMatch relies on the index + 1 == KnowColor match
static internal uint[] ArgbValues = new uint[] {
0x00000000, /* 000 - Empty */
0xFFD4D0C8, /* 001 - ActiveBorder */
// correct system colors outside Windows
}
- // Windows values are without alpha, force it to opaque (or everything will be transparent)
+ // Windows values are in BGR format and without alpha
+ // so we force it to opaque (or everything will be transparent) and reverse B and R
static uint GetSysColor (GetSysColorIndex index)
{
- return 0xFF000000 | GDIPlus.Win32GetSysColor (index);
+ uint bgr = GDIPlus.Win32GetSysColor (index);
+ return 0xFF000000 | (bgr & 0xFF) << 16 | (bgr & 0xFF00) | (bgr >> 16);
}
static void RetrieveWindowsSystemColors ()
c.state = (short) (Color.ColorType.ARGB | Color.ColorType.Known | Color.ColorType.Named);
if ((n < 27) || (n > 169))
c.state |= (short) Color.ColorType.System;
- c.value = ArgbValues [n];
+ c.Value = ArgbValues [n];
#if ONLY_1_1
c.name = GetName (n);
#endif
return GetName ((short)kc);
}
+ // FIXME: Linear scan
public static Color FindColorMatch (Color c)
{
uint argb = (uint) c.ToArgb ();
- for (int i = 0; i < KnownColors.ArgbValues.Length; i++) {
+
+ // 1-based
+ const int first_real_color_index = (int) KnownColor.AliceBlue;
+ const int last_real_color_index = (int) KnownColor.YellowGreen;
+
+ for (int i = first_real_color_index - 1; i < last_real_color_index; i++) {
if (argb == KnownColors.ArgbValues [i])
return KnownColors.FromKnownColor ((KnownColor)i);
- }
+ }
+
return Color.Empty;
}