简体   繁体   English

RGB颜色为HSL字节

[英]RGB color to HSL bytes

I've seen some implementations for converting RGB to HSL. 我见过一些将RGB转换为HSL的实现。 Most are accurate and work in both directions. 大多数是准确的,并在两个方向工作。

To me its not important that it will work in 2 directions (no need to put back to RGB) But i want code that returns values from 0 to 255 max, also for the Hue channel. 对我而言,它在两个方向上工作并不重要(不需要回到RGB)但我希望代码能够返回0到255最大值,也适用于Hue通道。 And I wouldnt like to do devisions like Hue/360*250 i am searching for integer based math no Dwords (its for another system), nice would be some kind of boolean logix (and/or/xor) 而且我不想做像Hue / 360 * 250这样的设计我正在寻找基于整数的数学没有Dwords(它用于另一个系统),很好会是某种布尔logix(和/或/ xor)

It should not do any integer or real number based math, the goal is code working only using byte math. 它不应该做任何基于整数或实数的数学,目标是代码只使用字节数学。

Maybe someone already has found such math when he used code like 也许有人在使用代码时已经找到了这样的数学

  1. c++ or c ++或
  2. c# or c#或
  3. python 蟒蛇

Which i would be able to translate to c++ 哪个我能翻译成c ++

检查colorsys模块,它有如下方法:

colorsys.rgb_to_hls(r,g,b)

colorsys.hls_to_rgb(h,l,s)

The easyrgb site has many code snippets for color space conversion. easyrgb网站有许多用于色彩空间转换的代码片段。 Here's the rgb->hsl code. 这是rgb-> hsl代码。

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

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