14 {0.8951f, 0.2664f, -0.1614f},
15 {-0.7502f, 1.7135f, 0.0367f},
16 {0.0389f, -0.0685f, 1.0296f},
33 {0.986992955f, -0.14705427f, 0.159962654f},
34 {0.432305276f, 0.518360257f, 0.049291227f},
35 {-0.0085286675f, 0.0400428213f, 0.968486726f},
41 {58661, 17459, -10578},
42 {-49165, 112296, 2405},
46 {64684, -9637, 10483},
74 const i64 acc =
static_cast<i64>(row[0]) *
static_cast<i64>(v[0])
75 +
static_cast<i64>(row[1]) *
static_cast<i64>(v[1])
76 +
static_cast<i64>(row[2]) *
static_cast<i64>(v[2]);
77 return static_cast<i32
>(acc >= 0 ? (acc + 32768) >> 16
78 : -((-acc + 32768) >> 16));
93 i32 destination_xy[2];
94 if (!adaptationWhiteQ16(source_white, source_xy) ||
95 !adaptationWhiteQ16(destination_white, destination_xy)) {
99 i64 destination_xyz[3];
104 const i32 source_v[3] = {
static_cast<i32
>(source_xyz[0]),
static_cast<i32
>(source_xyz[1]),
105 static_cast<i32
>(source_xyz[2])};
106 const i32 destination_v[3] = {
static_cast<i32
>(destination_xyz[0]),
107 static_cast<i32
>(destination_xyz[1]),
108 static_cast<i32
>(destination_xyz[2])};
110 for (
int i = 0; i < 3; ++i) {
112 const i32 destination_cone =
116 if (source_cone == 0) {
120 static_cast<i64>(destination_cone) * kAdaptationQ16One, source_cone);
122 for (
int row = 0; row < 3; ++row) {
123 for (
int col = 0; col < 3; ++col) {
127 for (
int k = 0; k < 3; ++k) {
134 if (
value > 2147483647LL ||
value < -2147483648LL) {
137 out->m[row][col] =
static_cast<i32
>(
value);
145 const i32 in[3] = {xyz[0], xyz[1], xyz[2]};
146 out_xyz[0] = dotAdaptationRowQ16(matrix.
m[0], in);
147 out_xyz[1] = dotAdaptationRowQ16(matrix.
m[1], in);
148 out_xyz[2] = dotAdaptationRowQ16(matrix.
m[2], in);
153 if (source ==
nullptr) {
157 for (
int row = 0; row < 3; ++row) {
158 for (
int col = 0; col < 3; ++col) {
160 static_cast<i64>(adaptation.m[row][0]) * source->m[0][col]
161 +
static_cast<i64>(adaptation.m[row][1]) * source->m[1][col]
162 +
static_cast<i64>(adaptation.m[row][2]) * source->m[2][col];
163 result.m[row][col] =
static_cast<i32
>(
164 acc >= 0 ? (acc + 32768) >> 16 : -((-acc + 32768) >> 16));
fl::UISlider scale("Scale", 4,.1, 4,.1)
Shared colorimetric primitives reusable by the RGBW and (future) RGB colorimetric paths (issue #3255)...
bool adaptationWhiteQ16(Chromaticity c, i32(&out)[2]) FL_NO_EXCEPT
A white point, converted from float by its bits, inside the open unit square with a non-zero y – the ...
constexpr i32 kAdaptationQ16One
i32 dotAdaptationRowQ16(const i32(&row)[3], const i32(&v)[3]) FL_NO_EXCEPT
i32 dotRowQ16(const i32(&row)[3], const i32(&v)[3]) FL_NO_EXCEPT
One s16.16 matrix row against a vector, rounded and saturated.
i64 roundedDivideQ16(i64 numerator, i64 denominator) FL_NO_EXCEPT
The s16.16 building blocks the bind-time builders share.
const i32 kBradfordInverseQ16[3][3]
const float kBradfordInverse[3][3]
Its inverse, precomputed.
const float kBradford[3][3]
ICC linear Bradford cone-response matrix.
const i32 kBradfordQ16[3][3]
The two matrices above in s16.16, rounded from the float32 values, so the bind-time build needs no fl...
bool xyzColumnQ16(const i32(&xy)[2], i32 luminance, i64(&column)[3]) FL_NO_EXCEPT
XYZ of chromaticity xy at luminance luminance, all s16.16; false for a non-positive or out-of-simplex...
Compile-time linker keep-alive hook for a single fl::Bus.
constexpr int type_rank< T >::value
void foldAdaptationIntoSourceMatrix(const AdaptationMatrixQ16 &adaptation, SourceMatrixQ16 *source) FL_NO_EXCEPT
Pre-multiply the adaptation into a source matrix, in place.
expected< T, E > result
Alias for expected (Rust-style naming)
InputGamut g FL_NO_EXCEPT
void adaptXyzQ16(const AdaptationMatrixQ16 &matrix, const i32(&xyz)[3], i32(&out_xyz)[3]) FL_NO_EXCEPT
Adapt one XYZ triple.
bool buildBradfordMatrixQ16(Chromaticity source_white, Chromaticity destination_white, AdaptationMatrixQ16 *out) FL_NO_EXCEPT
Build the Bradford transform from source_white to destination_white.
bool q16FromFloatBits(float value, i32 *out) FL_NO_EXCEPT
s16.16 of a float, rounded to nearest, computed from its IEEE-754 bits with integer arithmetic only –...
Base definition for an LED controller.
A collapsed adaptation transform in s16.16.
Source-primaries matrix in s16.16, rows ordered X, Y, Z.
CIE 1931 xy chromaticity, independent of encoded storage and chipset.