简体   繁体   English

在.Net Compact Framework中将OLE颜色转换为System.Drawing.Color

[英]Convert OLE Color to System.Drawing.Color in .Net Compact Framework

I receive an OLE color from a 3rd party system and I need to convert this to a System.Drawing.Color . 我从第三方系统收到OLE颜色,我需要将其转换为System.Drawing.Color

On the full .Net Framework I can use ColorTranslator.FromOle(int oleColor) 在完整的.Net Framework上,我可以使用ColorTranslator.FromOle(int oleColor)

to perform this conversion however this doesn't exist in the Compact framework. 执行此转换,但是Compact框架中不存在此转换。 Any idea how to perform this conversion? 知道如何执行此转换吗?

Thanks 谢谢


Below is the answer. 以下是答案。

int oleColor = 16711680;   // Blue
Color argbColor;

argbColor = Color.FromArgb((byte)(oleColor & 0xff), (byte)((oleColor >> 8) & 0xff), (byte)((oleColor >> 0x10) & 0xff));

You can download the tiral version of Reflector and inspect the code of ColorTranslator.FromOle method. 您可以下载Reflector的正式版本,并检查ColorTranslator.FromOle方法的代码。

Basically, There is a big switch case block where each case returns a Color structure with Color.FromKnownColor method. 基本上,有一个很大的切换用例块,其中每种情况都使用Color.FromKnownColor方法返回Color结构。

截图

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM