[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [16667] trunk/blender/source/blender: Added three XYZ color space options in code, will be activated later.
Ton Roosendaal
ton at blender.org
Mon Sep 22 11:09:03 CEST 2008
Revision: 16667
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=16667
Author: ton
Date: 2008-09-22 11:09:03 +0200 (Mon, 22 Sep 2008)
Log Message:
-----------
Added three XYZ color space options in code, will be activated later.
Thanks matt for the typing work :)
Modified Paths:
--------------
trunk/blender/source/blender/blenlib/BLI_arithb.h
trunk/blender/source/blender/blenlib/intern/arithb.c
trunk/blender/source/blender/render/intern/source/pixelshading.c
Modified: trunk/blender/source/blender/blenlib/BLI_arithb.h
===================================================================
--- trunk/blender/source/blender/blenlib/BLI_arithb.h 2008-09-22 07:52:08 UTC (rev 16666)
+++ trunk/blender/source/blender/blenlib/BLI_arithb.h 2008-09-22 09:09:03 UTC (rev 16667)
@@ -322,6 +322,10 @@
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 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);
Modified: trunk/blender/source/blender/blenlib/intern/arithb.c
===================================================================
--- trunk/blender/source/blender/blenlib/intern/arithb.c 2008-09-22 07:52:08 UTC (rev 16666)
+++ trunk/blender/source/blender/blenlib/intern/arithb.c 2008-09-22 09:09:03 UTC (rev 16667)
@@ -3453,13 +3453,27 @@
*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)
+/*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)
{
- *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);
+ 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
Modified: trunk/blender/source/blender/render/intern/source/pixelshading.c
===================================================================
--- trunk/blender/source/blender/render/intern/source/pixelshading.c 2008-09-22 07:52:08 UTC (rev 16666)
+++ trunk/blender/source/blender/render/intern/source/pixelshading.c 2008-09-22 09:09:03 UTC (rev 16667)
@@ -594,7 +594,7 @@
colorxyz[1] /= scale;
colorxyz[2] /= scale;
- xyz_to_rgb(colorxyz[0], colorxyz[1], colorxyz[2], &colf[0], &colf[1], &colf[2]);
+ xyz_to_rgb(colorxyz[0], colorxyz[1], colorxyz[2], &colf[0], &colf[1], &colf[2], BLI_CS_SMPTE);
ClipColor(colf);
}
More information about the Bf-blender-cvs
mailing list