如何使用 .NET 将旧版 (OLE) 颜色转换为 (A)RGB?

发布于 2024-08-30 11:08:02 字数 378 浏览 16 评论 0原文

我在旧版 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

坦然微笑 2024-09-06 11:08:02

如果由于某种原因你不能使用 System.Drawing lib(例如在 Azure 函数中),那么你可以这样计算:

                var ole = 6579300;
                var red = ole % 256;
                var green = (ole / 256) % 256;
                var blue = (ole / 65536) % 256;
                var backToOle = red + (green * 256) + (blue * 256 * 256);

If from some reason you cannot use System.Drawing lib (e.g. in Azure function) than you can calculate like this:

                var ole = 6579300;
                var red = ole % 256;
                var green = (ole / 256) % 256;
                var blue = (ole / 65536) % 256;
                var backToOle = red + (green * 256) + (blue * 256 * 256);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文