views:

104

answers:

1

I have a list of color values encoded as signed integers (OLE I think) in a legacy INI file that I need to translate into (A)RGB values with .NET. An INI example:

[INI_Section]
Color=-2147483633

Doing something like:

Color.FromArgb(-2147483633)

gives an alpha-blended version of a color that is not at all what I expect. I think that a value like -2147483633 is supposed to represent a system-defined, or named color like ButtonFace. Is there a .NET method for translating these legacy colors properly? Note that pInvoke to OlePro32.dll is not an option.

+6  A: 

You can use ColorTranslator.FromOle to do the conversion.
http://msdn.microsoft.com/en-us/library/system.drawing.colortranslator.fromole.aspx

Chris Taylor
Perfect. Thanks.
Paul Sasik
+1. A bit more from the docs. "If an OLE_COLOR has its high-order bit set, the low-order byte is treated as a system color index" http://support.microsoft.com/kb/131101 So `8000000F` is indeed *button face* because the system colour COLOR_BTNFACE is at index 15 http://msdn.microsoft.com/en-us/library/ms724371(VS.85).aspx
MarkJ