mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2025-03-01 10:33:28 +00:00
Saturation & Brightness/Value Gain using Oklab color space (#1477)
* Imported Oklab reference implementation * Add Okhsv conversions * Fixed formatting error * Add saturation and value gain to schemas * Add english translation for saturation, value gain * Created OkhsvTransform * Make OkhsvTransform configurable * Apply OkhvsTransform * Clamped values during transform * Precalculate isIdentity in OkhsvTransform * Skip OkhsvTransform if it is the identity function * Added changelog message * Allow for full desaturation * Imported recommended changes by LordGrey * Fixed typo in constant * Fixed anti-pattern in ok_color.h * Correct indentions * Correct remote-control * Limited maximum gain settings to practical range * Renane valueGain to brightnessGain for clarity and understanding Co-authored-by: LordGrey <lordgrey.emmel@gmail.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#include <utils/ColorSys.h>
|
||||
|
||||
#include <QColor>
|
||||
#include <oklab/ok_color.h>
|
||||
|
||||
inline uint8_t clamp(int x)
|
||||
{
|
||||
@@ -56,3 +57,22 @@ void ColorSys::yuv2rgb(uint8_t y, uint8_t u, uint8_t v, uint8_t &r, uint8_t &g,
|
||||
g = clamp((298 * c - 100 * d - 208 * e + 128) >> 8);
|
||||
b = clamp((298 * c + 516 * d + 128) >> 8);
|
||||
}
|
||||
|
||||
void ColorSys::rgb2okhsv(uint8_t red, uint8_t green, uint8_t blue, double & hue, double & saturation, double & value)
|
||||
{
|
||||
ok_color::HSV color = ok_color::srgb_to_okhsv({ static_cast<float>(red) / 255.F,
|
||||
static_cast<float>(green) / 255.F,
|
||||
static_cast<float>(blue) / 255.F
|
||||
});
|
||||
hue = color.h;
|
||||
saturation = color.s;
|
||||
value = color.v;
|
||||
}
|
||||
|
||||
void ColorSys::okhsv2rgb(double hue, double saturation, double value, uint8_t & red, uint8_t & green, uint8_t & blue)
|
||||
{
|
||||
ok_color::RGB color = ok_color::okhsv_to_srgb({ static_cast<float>(hue), static_cast<float>(saturation), static_cast<float>(value) });
|
||||
red = static_cast<uint8_t>(std::lround(color.r * 255));
|
||||
green = static_cast<uint8_t>(std::lround(color.g * 255));
|
||||
blue = static_cast<uint8_t>(std::lround(color.b * 255));
|
||||
}
|
||||
|
Reference in New Issue
Block a user