如何在C#中突出显示给定的颜色 [英] How to highlight a given color in C#
问题描述
如何在C#中突出显示给定的颜色。用户为我要显示的对象选择任意颜色。选择对象时,我要突出显示它们。
How could I highlight a given color in C#. The user selects an arbitrary color for the objects I'm displaying. When I select the objects I would like to highlight them.
您知道这样做的最好方法是什么吗?
Do you know what is the best way to do this?
我需要这样的东西:
private Color HighLight(Color c)
{
//calculate a highlight color from c
return highlighted;
}
预先感谢
推荐答案
您需要将RGB颜色转换为HSL(遵循 post )。然后增加L值(亮度)并转换回RGB。直接更改R,G,B不会使您看起来突出的颜色看起来自然。但是,这完全取决于您将在应用程序中执行的操作。转换可提供最佳结果,但需要大量代码。另一方面,直接更改RGB将非常快速。
You need to convert your RGB color to HSL (follow this post). Then increase L value (lightness) and convert back to RGB. Changing R, G, B directly will not give you "natural" looking of highlighted color. But all depends of what will you do in your application. Converting gives best result but need a lot of code. On the other hand, changing RGB directly will work very fast.
这篇关于如何在C#中突出显示给定的颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!