path: root/color.h
diff options
authorH. Peter Anvin <hpa@zytor.com>2017-09-12 11:11:41 -0700
committerH. Peter Anvin <hpa@zytor.com>2017-09-12 11:26:50 -0700
commit7b31610abcf59c85b31a0b7c3db3a33ed82f71fd (patch)
treead7fac9c532e798a3dd178994d784d91595d9765 /color.h
parentb92ea995371cec99e0366f6a341ca1e35e1f7211 (diff)
Initialize RGB <-> XYZ matrices in C code, to make other LEDs easierHEADmaster
Initialize the RGB <-> XYZ matrices explicitly in C code, eliminating the need to use octave, and making it easier to specify different primaries for other LEDs.
Diffstat (limited to 'color.h')
1 files changed, 13 insertions, 3 deletions
diff --git a/color.h b/color.h
index e4811c4..7c7ab8b 100644
--- a/color.h
+++ b/color.h
@@ -54,9 +54,19 @@ struct cie_Luv const_func XYZ_to_Luv(struct cie_XYZ XYZ, struct cie_XYZ white);
struct cie_XYZ const_func Luv_to_XYZ(struct cie_Luv Luv, struct cie_XYZ white);
struct cie_xy pure_func spectral(double nm);
struct cie_XYZ pure_func planckian(double T);
-struct RGB const_func XYZ_to_RGB(struct cie_XYZ XYZ);
-struct cie_XYZ const_func RGB_to_XYZ(struct RGB RGB);
+struct RGB pure_func XYZ_to_RGB(struct cie_XYZ XYZ);
+struct cie_XYZ pure_func RGB_to_XYZ(struct RGB RGB);
+void RGBXYZ_init(void);
struct RGB const_func XYZ_to_sRGB(struct cie_XYZ XYZ);
-struct cie_XYZ sRGB_to_XYZ(struct RGB sRGB);
+struct cie_XYZ const_func sRGB_to_XYZ(struct RGB sRGB);
+/* y = A x */
+static inline void color_mat_multiply(double y[3], const double A[3][3],
+ const double x[3])
+ y[0] = A[0][0] * x[0] + A[0][1] * x[1] + A[0][2] * x[2];
+ y[1] = A[1][0] * x[0] + A[1][1] * x[1] + A[1][2] * x[2];
+ y[2] = A[2][0] * x[0] + A[2][1] * x[1] + A[2][2] * x[2];
+void color_mat_inverse(double X[3][3], const double A[3][3]); /* X = A^-1 */
#endif /* COLOR_H */