如何使用 .NET 将旧版 (OLE) 颜色转换为 (A)RGB?
我在旧版 INI 文件中有一个编码为有符号整数(我认为是 OLE)的颜色值列表,我需要使用 .NET 将其转换为 (A)RGB 值。 INI 示例:
<前><代码>[INI_Section] 颜色=-2147483633
做类似的事情:
Color.FromArgb(-2147483633)
给出颜色的 alpha 混合版本,这根本不是我所期望的。我认为像 -2147483633 这样的值应该代表系统定义的颜色,或者像 ButtonFace 这样的命名颜色。是否有 .NET 方法可以正确转换这些旧颜色?请注意,pInvoke 到 OlePro32.dll 不是一个选项。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用 ColorTranslator.FromOle 进行转换。
http://msdn.microsoft.com/en-us /library/system.drawing.colortranslator.fromole.aspx
You can use ColorTranslator.FromOle to do the conversion.
http://msdn.microsoft.com/en-us/library/system.drawing.colortranslator.fromole.aspx
如果由于某种原因你不能使用 System.Drawing lib(例如在 Azure 函数中),那么你可以这样计算:
If from some reason you cannot use System.Drawing lib (e.g. in Azure function) than you can calculate like this: