Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@gmail.com>2018-10-12 17:42:34 +0300
committerBrecht Van Lommel <brechtvanlommel@gmail.com>2018-12-13 21:25:46 +0300
commitf527ce5b2f5bb300a7fe55db33d1e3a4da8051c7 (patch)
treedf1226d253b2a7c2e66cba75b37f9ec0a475c288 /source/blender/blenlib
parent6601a89650f92454aa57bc01bedebd4086f6d98d (diff)
Color management: add OCIO aware utility functions for transform to/from XYZ.
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r--source/blender/blenlib/BLI_math_color.h5
-rw-r--r--source/blender/blenlib/intern/math_color.c81
2 files changed, 0 insertions, 86 deletions
diff --git a/source/blender/blenlib/BLI_math_color.h b/source/blender/blenlib/BLI_math_color.h
index 3653191232c..7fe890edeec 100644
--- a/source/blender/blenlib/BLI_math_color.h
+++ b/source/blender/blenlib/BLI_math_color.h
@@ -64,7 +64,6 @@ void hsl_to_rgb_v(const float hcl[3], float r_rgb[3]);
void hex_to_rgb(char *hexcol, float *r, float *g, float *b);
void yuv_to_rgb(float y, float u, float v, float *lr, float *lg, float *lb, int colorspace);
void ycc_to_rgb(float y, float cb, float cr, float *lr, float *lg, float *lb, int colorspace);
-void xyz_to_rgb(float x, float y, float z, float *r, float *g, float *b, int colorspace);
void cpack_to_rgb(unsigned int col, float *r, float *g, float *b);
/***************** Conversion from RGB ********************/
@@ -79,8 +78,6 @@ void rgb_to_hsl_compat(float r, float g, float b, float *lh, float *ls, float *l
void rgb_to_hsl_compat_v(const float rgb[3], float r_hsl[3]);
void rgb_to_hsv_compat(float r, float g, float b, float *lh, float *ls, float *lv);
void rgb_to_hsv_compat_v(const float rgb[3], float r_hsv[3]);
-void rgb_to_lab(float r, float g, float b, float *ll, float *la, float *lb);
-void rgb_to_xyz(float r, float g, float b, float *x, float *y, float *z);
unsigned int rgb_to_cpack(float r, float g, float b);
unsigned int hsv_to_cpack(float h, float s, float v);
@@ -131,8 +128,6 @@ void rgba_uchar_to_float(float r_col[4], const unsigned char col_ub[4]);
void rgb_float_to_uchar(unsigned char r_col[3], const float col_f[3]);
void rgba_float_to_uchar(unsigned char r_col[4], const float col_f[4]);
-void xyz_to_lab(float x, float y, float z, float *l, float *a, float *b);
-
MINLINE float rgb_to_grayscale(const float rgb[3]);
MINLINE unsigned char rgb_to_grayscale_byte(const unsigned char rgb[3]);
diff --git a/source/blender/blenlib/intern/math_color.c b/source/blender/blenlib/intern/math_color.c
index 9399646bedf..09a5762e4e0 100644
--- a/source/blender/blenlib/intern/math_color.c
+++ b/source/blender/blenlib/intern/math_color.c
@@ -357,29 +357,6 @@ void hsv_clamp_v(float hsv[3], float v_max)
CLAMP(hsv[2], 0.0f, v_max);
}
-/*http://brucelindbloom.com/index.html?Eqn_RGB_XYZ_Matrix.html */
-
-void xyz_to_rgb(float xc, float yc, float zc, float *r, float *g, float *b, int colorspace)
-{
- switch (colorspace) {
- case BLI_XYZ_SMPTE:
- *r = (3.50570f * xc) + (-1.73964f * yc) + (-0.544011f * zc);
- *g = (-1.06906f * xc) + (1.97781f * yc) + (0.0351720f * zc);
- *b = (0.0563117f * xc) + (-0.196994f * yc) + (1.05005f * zc);
- break;
- case BLI_XYZ_REC709_SRGB:
- *r = (3.240476f * xc) + (-1.537150f * yc) + (-0.498535f * zc);
- *g = (-0.969256f * xc) + (1.875992f * yc) + (0.041556f * zc);
- *b = (0.055648f * xc) + (-0.204043f * yc) + (1.057311f * zc);
- break;
- case BLI_XYZ_CIE:
- *r = (2.28783848734076f * xc) + (-0.833367677835217f * yc) + (-0.454470795871421f * zc);
- *g = (-0.511651380743862f * xc) + (1.42275837632178f * yc) + (0.0888930017552939f * zc);
- *b = (0.00572040983140966f * xc) + (-0.0159068485104036f * yc) + (1.0101864083734f * zc);
- break;
- }
-}
-
/**
* We define a 'cpack' here as a (3 byte color code) number that can be expressed like 0xFFAA66 or so.
* for that reason it is sensitive for endianness... with this function it works correctly.
@@ -618,64 +595,6 @@ void BLI_init_srgb_conversion(void)
BLI_color_to_srgb_table[i] = (unsigned short)(b * 0x100);
}
}
-static float inverse_srgb_companding(float v)
-{
- if (v > 0.04045f) {
- return powf((v + 0.055f) / 1.055f, 2.4f);
- }
- else {
- return v / 12.92f;
- }
-}
-
-/**
- * \note Does sRGB to linear conversion
- */
-void rgb_to_xyz(float r, float g, float b, float *x, float *y, float *z)
-{
- r = inverse_srgb_companding(r) * 100.0f;
- g = inverse_srgb_companding(g) * 100.0f;
- b = inverse_srgb_companding(b) * 100.0f;
-
- *x = r * 0.412453f + g * 0.357580f + b * 0.180423f;
- *y = r * 0.212671f + g * 0.715160f + b * 0.072169f;
- *z = r * 0.019334f + g * 0.119193f + b * 0.950227f;
-}
-
-static float xyz_to_lab_component(float v)
-{
- const float eps = 0.008856f;
- const float k = 903.3f;
-
- if (v > eps) {
- return powf(v, 1.0f / 3.0f);
- }
- else {
- return (k * v + 16.0f) / 116.0f;
- }
-}
-
-void xyz_to_lab(float x, float y, float z, float *l, float *a, float *b)
-{
- const float xr = x / 95.047f;
- const float yr = y / 100.0f;
- const float zr = z / 108.883f;
-
- const float fx = xyz_to_lab_component(xr);
- const float fy = xyz_to_lab_component(yr);
- const float fz = xyz_to_lab_component(zr);
-
- *l = 116.0f * fy - 16.0f;
- *a = 500.0f * (fx - fy);
- *b = 200.0f * (fy - fz);
-}
-
-void rgb_to_lab(float r, float g, float b, float *ll, float *la, float *lb)
-{
- float x, y, z;
- rgb_to_xyz(r, g, b, &x, &y, &z);
- xyz_to_lab(x, y, z, ll, la, lb);
-}
/* ****************************** blackbody ******************************** */