|
| template<class HSXType , class TReal > |
| void | addLightness (TReal &r, TReal &g, TReal &b, TReal light) |
| |
| template<class T > |
| KoColorSpaceMathsTraits< T >::compositetype | Arithmetic::and (T a, T b) |
| |
| template<class T > |
| T | Arithmetic::blend (T src, T srcAlpha, T dst, T dstAlpha, T cfValue) |
| |
| template<class T > |
| T | Arithmetic::clamp (typename KoColorSpaceMathsTraits< T >::compositetype a) |
| |
| template<class T > |
| T | Arithmetic::clampChannelToSDR (T a) |
| |
| template<class T > |
| T | Arithmetic::clampChannelToSDRBottom (T a) |
| |
| template<class T > |
| T | Arithmetic::clampToSDR (typename KoColorSpaceMathsTraits< T >::compositetype a) |
| |
| template<class T > |
| T | Arithmetic::clampToSDRBottom (typename KoColorSpaceMathsTraits< T >::compositetype a) |
| |
| template<class T > |
| T | Arithmetic::clampToSDRTop (typename KoColorSpaceMathsTraits< T >::compositetype a) |
| |
| template<class T > |
| KoColorSpaceMathsTraits< T >::compositetype | Arithmetic::div (T a, T b) |
| |
| template<class T , typename composite_type = typename KoColorSpaceMathsTraits<T>::compositetype> |
| composite_type | Arithmetic::divideInCompositeSpace (composite_type a, composite_type b) |
| |
| template<class T > |
| T | Arithmetic::epsilon () |
| |
| int | float2int (double x) |
| |
| int | float2int (float x) |
| |
| template<class TReal > |
| TReal | getHue (TReal r, TReal g, TReal b) |
| |
| template<class HSXType , class TReal > |
| static TReal | getLightness (TReal r, TReal g, TReal b) |
| |
| template<class TReal > |
| void | getRGB (TReal &r, TReal &g, TReal &b, TReal hue) |
| |
| template<class HSXType , class TReal > |
| static TReal | getSaturation (TReal r, TReal g, TReal b) |
| |
| template<class T > |
| T | Arithmetic::halfValue () |
| |
| template<class T > |
| T | Arithmetic::inv (T a) |
| |
| template<typename T > |
| static bool | Arithmetic::isHalfValueFuzzy (T v) |
| |
| template<typename T > |
| static bool | Arithmetic::isUnitValueClampedFuzzy (T v) |
| |
| template<typename T > |
| bool | Arithmetic::isUnitValueClampedStrict (T value) |
| |
| template<typename T > |
| static bool | Arithmetic::isUnitValueFuzzy (T v) |
| |
| template<typename T > |
| bool | Arithmetic::isUnitValueStrict (T value) |
| |
| template<typename T > |
| T | Arithmetic::isUnsafeAsDivisor (T value) |
| |
| template<typename T > |
| static bool | Arithmetic::isZeroValueClampedFuzzy (T v) |
| |
| template<typename T > |
| bool | Arithmetic::isZeroValueClampedStrict (T value) |
| |
| template<typename T > |
| static bool | Arithmetic::isZeroValueFuzzy (T v) |
| |
| template<typename T > |
| bool | Arithmetic::isZeroValueStrict (T value) |
| |
| template<class T > |
| T | Arithmetic::lerp (T a, T b, T alpha) |
| |
| template<class T > |
| T | Arithmetic::max (T a, T b, T c) |
| |
| template<class T > |
| T | Arithmetic::min (T a, T b, T c) |
| |
| template<class T > |
| KoColorSpaceMathsTraits< T >::compositetype | Arithmetic::mod (T a, T b) |
| |
| template<class T > |
| T | Arithmetic::mul (T a, T b) |
| |
| template<class T > |
| T | Arithmetic::mul (T a, T b, T c) |
| |
| template<class T , typename composite_type = typename KoColorSpaceMathsTraits<T>::compositetype> |
| composite_type | Arithmetic::multiplyInCompositeSpace (composite_type a, composite_type b) |
| |
| template<class T > |
| KoColorSpaceMathsTraits< T >::compositetype | Arithmetic::or (T a, T b) |
| |
| template<class TRet , class T > |
| TRet | Arithmetic::scale (T a) |
| |
| template<class HSXType , class TReal > |
| void | setLightness (TReal &r, TReal &g, TReal &b, TReal light) |
| |
| template<class HSXType , class TReal > |
| void | setSaturation (TReal &r, TReal &g, TReal &b, TReal sat) |
| |
| template<class HSXType , class TReal > |
| void | ToneMapping (TReal &r, TReal &g, TReal &b) |
| |
| template<class T > |
| T | Arithmetic::unionShapeOpacity (T a, T b) |
| |
| template<class T > |
| T | Arithmetic::unitValue () |
| |
| template<class T > |
| KoColorSpaceMathsTraits< T >::compositetype | Arithmetic::xor (T a, T b) |
| |
| template<class T > |
| T | Arithmetic::zeroValue () |
| |
template<class HSXType , class TReal >
| void ToneMapping |
( |
TReal & | r, |
|
|
TReal & | g, |
|
|
TReal & | b ) |
|
inline |
The tonemapping method we use does not support lightness values below 0.0, so we just clamp the value.
TODO: use proper HSV/HSI shape-tracking clamping methods we use in kis_hsv_adjustment.cpp
The tonemapping method we use does not support lightness values above 1.0, so we just clamp the value.
TODO: use proper HSV/HSI shape-tracking clamping methods we use in kis_hsv_adjustment.cpp
Definition at line 1052 of file KoColorSpaceMaths.h.
1053{
1055
1056
1057 TReal l = HSXType::getLightness(r, g, b);
1058 TReal n =
min(r, g, b);
1059 TReal
x =
max(r, g, b);
1060
1061 if(n < TReal(0.0)) {
1062 if (isZeroValueClampedFuzzy<float>(l)) {
1070 r = g =
b = TReal(0.0);
1071 } else {
1072 const TReal stretch = l - n;
1073
1074 if (stretch < std::numeric_limits<TReal>::epsilon()) {
1075 r = g =
b = TReal(0.0);
1076 } else {
1077 TReal iln = TReal(1.0) / stretch;
1078 r = l + ((
r-l) * l) * iln;
1079 g = l + ((g-l) * l) * iln;
1080 b = l + ((
b-l) * l) * iln;
1081 }
1082 }
1083 }
1084
1085 if(x > TReal(1.0)) {
1086 auto setFallbackValues = [&] () {
1087 if constexpr (HSXType::lightnessIsAverage) {
1088 r = g =
b = TReal(1.0);
1089 } else {
1090 r = qMin(r, TReal(1.0));
1091 g = qMin(g, TReal(1.0));
1092 b = qMin(b, TReal(1.0));
1093 }
1094 };
1095
1096 if (l > TReal(1.0)) {
1104 setFallbackValues();
1105 } else {
1106 const TReal stretch =
x - l;
1107
1108 if (stretch < std::numeric_limits<TReal>::epsilon()) {
1109 setFallbackValues();
1110 } else {
1111 TReal il = TReal(1.0) - l;
1112 TReal ixl = TReal(1.0) / stretch;
1113
1114 r = l + ((
r-l) * il) * ixl;
1115 g = l + ((g-l) * il) * ixl;
1116 b = l + ((
b-l) * il) * ixl;
1117 }
1118 }
1119 }
1120}