[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [43520] trunk/blender/source/blender: add utility functions linearrgb_to_srgb_uchar4,

Campbell Barton ideasman42 at gmail.com
Thu Jan 19 09:22:31 CET 2012


Revision: 43520
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=43520
Author:   campbellbarton
Date:     2012-01-19 08:22:23 +0000 (Thu, 19 Jan 2012)
Log Message:
-----------
add utility functions linearrgb_to_srgb_uchar4,
linearrgb_to_srgb_uchar3, was being done inline.

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/intern/node.c
    trunk/blender/source/blender/blenlib/intern/math_color_inline.c
    trunk/blender/source/blender/editors/uvedit/uvedit_ops.c
    trunk/blender/source/blender/render/intern/source/rendercore.c

Modified: trunk/blender/source/blender/blenkernel/intern/node.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/node.c	2012-01-19 07:12:30 UTC (rev 43519)
+++ trunk/blender/source/blender/blenkernel/intern/node.c	2012-01-19 08:22:23 UTC (rev 43520)
@@ -790,16 +790,14 @@
 				unsigned char *tar= preview->rect+ 4*((preview->xsize*y) + x);
 				
 				if(do_manage) {
-					tar[0]= FTOCHAR(linearrgb_to_srgb(col[0]));
-					tar[1]= FTOCHAR(linearrgb_to_srgb(col[1]));
-					tar[2]= FTOCHAR(linearrgb_to_srgb(col[2]));
+					linearrgb_to_srgb_uchar4(tar, col);
 				}
 				else {
 					tar[0]= FTOCHAR(col[0]);
 					tar[1]= FTOCHAR(col[1]);
 					tar[2]= FTOCHAR(col[2]);
+					tar[3]= FTOCHAR(col[3]);
 				}
-				tar[3]= FTOCHAR(col[3]);
 			}
 			//else printf("prv out bound x y %d %d\n", x, y);
 		}

Modified: trunk/blender/source/blender/blenlib/intern/math_color_inline.c
===================================================================
--- trunk/blender/source/blender/blenlib/intern/math_color_inline.c	2012-01-19 07:12:30 UTC (rev 43519)
+++ trunk/blender/source/blender/blenlib/intern/math_color_inline.c	2012-01-19 08:22:23 UTC (rev 43520)
@@ -62,6 +62,34 @@
 	srgb[3] = linear[3];
 }
 
+MINLINE void linearrgb_to_srgb_uchar3(unsigned char srgb[4], const float linear[4])
+{
+	int r, g, b;
+
+	r = 255 * linearrgb_to_srgb(linear[0]) * 255;
+	g = 255 * linearrgb_to_srgb(linear[1]) * 255;
+	b = 255 * linearrgb_to_srgb(linear[2]) * 255;
+
+	srgb[0] = FTOCHAR(r);
+	srgb[1] = FTOCHAR(g);
+	srgb[2] = FTOCHAR(b);
+}
+
+MINLINE void linearrgb_to_srgb_uchar4(unsigned char srgb[4], const float linear[4])
+{
+	int r, g, b, a;
+
+	r = 255 * linearrgb_to_srgb(linear[0]) * 255;
+	g = 255 * linearrgb_to_srgb(linear[1]) * 255;
+	b = 255 * linearrgb_to_srgb(linear[2]) * 255;
+	a = 255 * linear[3];
+
+	srgb[0] = FTOCHAR(r);
+	srgb[1] = FTOCHAR(g);
+	srgb[2] = FTOCHAR(b);
+	srgb[3] = FTOCHAR(a);
+}
+
 /* predivide versions to work on associated/premultipled alpha. if this should
    be done or not depends on the background the image will be composited over,
    ideally you would never do color space conversion on an image with alpha

Modified: trunk/blender/source/blender/editors/uvedit/uvedit_ops.c
===================================================================
--- trunk/blender/source/blender/editors/uvedit/uvedit_ops.c	2012-01-19 07:12:30 UTC (rev 43519)
+++ trunk/blender/source/blender/editors/uvedit/uvedit_ops.c	2012-01-19 08:22:23 UTC (rev 43520)
@@ -103,7 +103,7 @@
 	return ED_space_image_show_uvedit(sima, obedit) && !(toolsettings->use_uv_sculpt);
 }
 
-static int ED_operator_uvmap_mesh(bContext *C)
+static int UNUSED_FUNCTION(ED_operator_uvmap_mesh)(bContext *C)
 {
 	Object *ob= CTX_data_active_object(C);
 

Modified: trunk/blender/source/blender/render/intern/source/rendercore.c
===================================================================
--- trunk/blender/source/blender/render/intern/source/rendercore.c	2012-01-19 07:12:30 UTC (rev 43519)
+++ trunk/blender/source/blender/render/intern/source/rendercore.c	2012-01-19 08:22:23 UTC (rev 43520)
@@ -2166,17 +2166,10 @@
 		}
 	}
 	else {
-		char *col= (char *)(bs->rect + bs->rectx*y + x);
+		unsigned char *col= (unsigned char *)(bs->rect + bs->rectx*y + x);
 
 		if (ELEM(bs->type, RE_BAKE_ALL, RE_BAKE_TEXTURE) &&	(R.r.color_mgt_flag & R_COLOR_MANAGEMENT)) {
-			float srgb[3];
-			srgb[0]= linearrgb_to_srgb(shr.combined[0]);
-			srgb[1]= linearrgb_to_srgb(shr.combined[1]);
-			srgb[2]= linearrgb_to_srgb(shr.combined[2]);
-			
-			col[0]= FTOCHAR(srgb[0]);
-			col[1]= FTOCHAR(srgb[1]);
-			col[2]= FTOCHAR(srgb[2]);
+			linearrgb_to_srgb_uchar3(col, shr.combined);
 		} else {
 			col[0]= FTOCHAR(shr.combined[0]);
 			col[1]= FTOCHAR(shr.combined[1]);



More information about the Bf-blender-cvs mailing list