C#单独的hsl值转换为rgb [英] C# seperate hsl values convert into rgb

查看:144
本文介绍了C#单独的hsl值转换为rgb的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个小应用程序来查找颜色的补色(使用颜色wheel的相反颜色.check 这个)。我搜索了那个。我有3个步骤。

1.获取颜色的HSL值。 (可以使用GetHue())

2.通过旋转180度来计算新的H值。(没关系)

3.将新的HSL值转换为颜色。

现在我在第3步。我分别有新的H,S,L值。我需要将它们转换成颜色。请任何身体帮助我。谢谢。

解决方案

Bob Powell的老人:[ ^ ]:将HSL转换为RGB是众所周知的您可以在网络上的许多地方找到的算法。奇怪的是,在ControlPaint类的内部,使用ControlPaint.Light( )或ControlPaint.DarkDark( )方法时会使用RGB到HSL,但不幸的是,Light,Dark和DarkDark设置的缩放是,至少可以说,野蛮并且不提供任何技巧。



Bob的文章有HSL => RGB的C#代码。



EasyRGB网站是关于色彩空间信息的一个很好的专业资源:[ ^ ]。



Adob​​e产品使用HSB(又名HSV)颜色空间,而不是HSL;有区别:[ ^ ]。



另一个很好的配色方案资源(不是来自Adobe)是Petr Stanicek的ColorSchemeDesigner:[ ^ ],imho a基于JavaScript的Web应用程序的杰作。该工具特别不涉及HSV / B或HSL。



有人断言.NET的HSL转换算法不遵循NTSC标准,并且劣等:[ ^ ] ...见Itai Bar-Heim的评论,其他。



如果您正在计算的是在给定人眼更大的加权的情况下,覆盖在另一种颜色上的文本的颜色将是最可读的(感知/相对亮度) 对于绿色的感知,以及对蓝色感知的较低权重等:[ ^ ]。

I am creating a small application to find the complementary color of a color(opposite color using color wheel.checkthis).I searched that.I got 3 steps.
1.Get HSL value of the color.(It is ok using GetHue())
2.Calculate the new H value by rotating 180 degrees.(It is OK)
3.Convert new HSL values into the color.
Now I am on step 3.I have new H,S,L values separately.I need to convert those into a color.Please any body help me.Thank you.

解决方案

An "oldie" from Bob Powell: [^]: "The conversion of HSL to RGB is a well known algorithm that you can find in numerous places on the web. Oddly enough, down in the bowels of the ControlPaint class, RGB to HSL is employed when you use the ControlPaint.Light(�) or ControlPaint.DarkDark(�) methods but also unfortunately the scaling of the Light, Dark and DarkDark settings are, to say the least, brutal and offer no finesse."

Bob's article has C# code for HSL => RGB.

The EasyRGB web-site is a good professional resource on color-space information: [^].

Adobe products use HSB (aka HSV) color-space, rather than HSL; there is a difference: [^].

Another great resource for color schemes (not from Adobe) is Petr Stanicek's ColorSchemeDesigner: [^], imho a masterpiece of a JavaScript based web-application. This facility does not deal with HSV/B, or HSL, specifically.

There are those who assert .NET's HSL conversion algorithms do not follow the NTSC standards, and are inferior: [^] ... see comments by Itai Bar-Heim, and others.

If what you are after is calculating what color for text overlaid on another color would be most readable (perceptual/relative luminance) given the human eye's greater "weighting" towards perception of green, and lower weighting for perception of blue, etc.: [^].


这篇关于C#单独的hsl值转换为rgb的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆