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:
authorTon Roosendaal <ton@blender.org>2008-09-22 13:09:03 +0400
committerTon Roosendaal <ton@blender.org>2008-09-22 13:09:03 +0400
commitd1dedb2cef4bf1dc2fd9b563dee7c1f45b79c173 (patch)
treef742b7f5ccf9dc4a7aca3d365c803d29d30ea9c8 /source/blender/blenlib
parentb7e8df1eff4fad158ad499df5bcc93e4aea40c90 (diff)
Added three XYZ color space options in code, will be activated later.
Thanks matt for the typing work :)
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r--source/blender/blenlib/BLI_arithb.h6
-rw-r--r--source/blender/blenlib/intern/arithb.c28
2 files changed, 26 insertions, 8 deletions
diff --git a/source/blender/blenlib/BLI_arithb.h b/source/blender/blenlib/BLI_arithb.h
index 4b858dcb503..e2e71a2fb1a 100644
--- a/source/blender/blenlib/BLI_arithb.h
+++ b/source/blender/blenlib/BLI_arithb.h
@@ -322,6 +322,10 @@ void i_window(
float mat[][4]
);
+#define BLI_CS_SMPTE 0
+#define BLI_CS_REC709 1
+#define BLI_CS_CIE 2
+
void hsv_to_rgb(float h, float s, float v, float *r, float *g, float *b);
void hex_to_rgb(char *hexcol, float *r, float *g, float *b);
void rgb_to_yuv(float r, float g, float b, float *ly, float *lu, float *lv);
@@ -329,7 +333,7 @@ void yuv_to_rgb(float y, float u, float v, float *lr, float *lg, float *lb);
void ycc_to_rgb(float y, float cb, float cr, float *lr, float *lg, float *lb);
void rgb_to_ycc(float r, float g, float b, float *ly, float *lcb, float *lcr);
void rgb_to_hsv(float r, float g, float b, float *lh, float *ls, float *lv);
-void xyz_to_rgb(float x, float y, float z, float *r, float *g, float *b);
+void xyz_to_rgb(float x, float y, float z, float *r, float *g, float *b, int colorspace);
int constrain_rgb(float *r, float *g, float *b);
void gamma_correct_rgb(float *r, float *g, float *b);
unsigned int hsv_to_cpack(float h, float s, float v);
diff --git a/source/blender/blenlib/intern/arithb.c b/source/blender/blenlib/intern/arithb.c
index c6634eb7707..888a5ab2f64 100644
--- a/source/blender/blenlib/intern/arithb.c
+++ b/source/blender/blenlib/intern/arithb.c
@@ -3453,13 +3453,27 @@ void rgb_to_hsv(float r, float g, float b, float *lh, float *ls, float *lv)
*lv = v;
}
-/*http://brucelindbloom.com/index.html?Eqn_RGB_XYZ_Matrix.html
- * SMPTE-C XYZ to RGB matrix*/
-void xyz_to_rgb(float xc, float yc, float zc, float *r, float *g, float *b)
-{
- *r = (3.50570 * xc) + (-1.73964 * yc) + (-0.544011 * zc);
- *g = (-1.06906 * xc) + (1.97781 * yc) + (0.0351720 * zc);
- *b = (0.0563117 * xc) + (-0.196994 * yc) + (1.05005 * zc);
+/*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_CS_SMPTE:
+ *r = (3.50570 * xc) + (-1.73964 * yc) + (-0.544011 * zc);
+ *g = (-1.06906 * xc) + (1.97781 * yc) + (0.0351720 * zc);
+ *b = (0.0563117 * xc) + (-0.196994 * yc) + (1.05005 * zc);
+ break;
+ case BLI_CS_REC709:
+ *r = (3.240476 * xc) + (-1.537150 * yc) + (-0.498535 * zc);
+ *g = (-0.969256 * xc) + (1.875992 * yc) + (0.041556 * zc);
+ *b = (0.055648 * xc) + (-0.204043 * yc) + (1.057311 * zc);
+ break;
+ case BLI_CS_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;
+ }
}
/*If the requested RGB shade contains a negative weight for