[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [29197] trunk/blender/source/blender/ editors/space_image/image_ops.c: Made the sample line tool of the image editor use color management if needed .

Xavier Thomas xavier.thomas.1980 at gmail.com
Thu Jun 3 22:25:02 CEST 2010


Revision: 29197
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=29197
Author:   xat
Date:     2010-06-03 22:25:00 +0200 (Thu, 03 Jun 2010)

Log Message:
-----------
Made the sample line tool of the image editor use color management if needed.

Modified Paths:
--------------
    trunk/blender/source/blender/editors/space_image/image_ops.c

Modified: trunk/blender/source/blender/editors/space_image/image_ops.c
===================================================================
--- trunk/blender/source/blender/editors/space_image/image_ops.c	2010-06-03 20:06:29 UTC (rev 29196)
+++ trunk/blender/source/blender/editors/space_image/image_ops.c	2010-06-03 20:25:00 UTC (rev 29197)
@@ -1663,6 +1663,7 @@
 {
 	SpaceImage *sima= CTX_wm_space_image(C);
 	ARegion *ar= CTX_wm_region(C);
+	Scene *scene= CTX_data_scene(C);
 	
 	int x_start= RNA_int_get(op->ptr, "xstart");
 	int y_start= RNA_int_get(op->ptr, "ystart");
@@ -1677,6 +1678,7 @@
 	int x1, y1, x2, y2;
 	int i, x, y;
 	float *fp;
+	float rgb[3];
 	unsigned char *cp;
 	
 	if (ibuf == NULL) {
@@ -1710,10 +1712,16 @@
 		} else {
 			if (ibuf->rect_float) {
 				fp= (ibuf->rect_float + (ibuf->channels)*(y*ibuf->x + x));
-				hist->data_r[i] = fp[0];
-				hist->data_g[i] = fp[1];
-				hist->data_b[i] = fp[2];
-				hist->data_luma[i] = (0.299f*fp[0] + 0.587f*fp[1] + 0.114f*fp[2]);
+
+				if (scene->r.color_mgt_flag & R_COLOR_MANAGEMENT)
+					linearrgb_to_srgb_v3_v3(rgb, fp);
+				else
+					copy_v3_v3(rgb, fp);
+
+				hist->data_r[i] = rgb[0];
+				hist->data_g[i] = rgb[1];
+				hist->data_b[i] = rgb[2];
+				hist->data_luma[i] = (0.299f*rgb[0] + 0.587f*rgb[1] + 0.114f*rgb[2]);
 			}
 			else if (ibuf->rect) {
 				cp= (unsigned char *)(ibuf->rect + y*ibuf->x + x);





More information about the Bf-blender-cvs mailing list