.Net颜色结构是否使用HSB或HSL颜色空间? [英] Does the .Net Color struct use an HSB or HSL colour space?

查看:140
本文介绍了.Net颜色结构是否使用HSB或HSL颜色空间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

据我了解, HSL和HSB颜色空间非常相似,都使用相同的0 -360色轮用于色相,饱和度则使用相同的0-1值.它们之间的一个区别是,在HSB模型中,您具有亮度,其中0是黑色,而1是在全强度下的颜色,而在HSL中,您具有明度/发光度,其中0仍然是黑色,而1是白色.

As I understand it HSL and HSB colour spaces are very similar, both use the same 0-360 colour wheel for hue and the same 0-1 value for saturation. The one difference between them is that in the HSB model you have brightness, where 0 is black and 1 is the colour at full intensity, while in HSL you have lightness/luminosity, where 0 is still black but 1 is white.

.net Color结构使用RGB空间,但是具有GetHue()GetSaturation()GetBrightness()函数.

The .net Color struct uses the RGB space, but has GetHue(), GetSaturation() and GetBrightness() functions.

此处的文档令人困惑.对于GetBrightness():

The documentation here is confusing. For GetBrightness():

/// <summary>Gets the hue-saturation-brightness (HSB) brightness value for this 
/// System.Drawing.Color structure.</summary>

好吧,这很有意义,.Net似乎正在使用HSB ...

Ok, so makes sense, .Net appears to be using HSB...

/// <returns>The brightness of this System.Drawing.Color. The brightness ranges 
/// from 0.0 through 1.0, where 0.0 represents black and 1.0 represents white.
/// </returns>

Er ...因此最大值代表白色,而不是最亮的颜色.尽管他们的文档和命名始终指的是亮度,但我很确定返回的值实际上是 lightness/luminosity ,即.Net实际上使用HSL模型,不是HSB.

Er... so the max value represents white, rather than the brightest colour. Despite the fact that their documents and naming consistently refers to brightness I'm pretty sure that the value returned is actually lightness/luminosity, i.e. .Net actually uses the HSL model and not HSB.

任何人都可以确认吗?是文档中的错误,GetBrightness()中的错误,还是我以某种方式误解了理论?

Can anyone confirm this? Is it an error in the documentation, an error in GetBrightness(), or am I misunderstanding the theory somehow?

推荐答案

您链接到的页面提供了各种颜色的L和V(也称为B)示例.将Color.FromArgb(255, 255, 0, 0).GetBrightness(0.5)的结果与示例进行比较表明,.NET正在使用HSL模型.选中Color.FromArgb(255, 128, 255, 255).GetSaturation(1.0)即可确认.

The page you linked to gives examples of L and V (aka B) for a range of colours. Comparing the result of Color.FromArgb(255, 255, 0, 0).GetBrightness (0.5) to the examples shows that .NET is using the HSL model. A check of Color.FromArgb(255, 128, 255, 255).GetSaturation (1.0) confirms it.

其他人也发现了同一件事,例如克里斯杰克逊(MSFT)在在.NET中从HSB转换为RGB :潜在的问题是,即使.NET Framework实际上是HSL,.NET Framework还是将色彩空间称为HSB.(颜色选择器控件正确地引用了它.)框架中的Color结构提供了GetBrightness()方法,在文档中描述为获取此Color结构的色相-饱和度-亮度(HSB)亮度值."这是错误的吗?您敢打赌.应将其称为GetLuminance()."

Others have discovered the same thing, e.g. Chris Jackson (MSFT) in Converting from HSB to RGB in .NET: "The underlying issue is that the .NET Framework refers to the color space as HSB even though it actually is HSL. (The color picker control refers to it correctly.) The Color structure in the framework provides a GetBrightness() method, described in the documentation as, "Gets the hue-saturation-brightness (HSB) brightness value for this Color structure." Is this wrong? You bet. It should be called GetLuminance()."

这篇关于.Net颜色结构是否使用HSB或HSL颜色空间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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