[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [30228] trunk/blender/source/blender/imbuf /intern/openexr/openexr_api.cpp: support for colorspace conversion when saving srgb float buffers ( from the sequencer) as openexr.

Campbell Barton ideasman42 at gmail.com
Mon Jul 12 16:54:05 CEST 2010


Revision: 30228
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=30228
Author:   campbellbarton
Date:     2010-07-12 16:54:05 +0200 (Mon, 12 Jul 2010)

Log Message:
-----------
support for colorspace conversion when saving srgb float buffers (from the sequencer) as openexr.

Modified Paths:
--------------
    trunk/blender/source/blender/imbuf/intern/openexr/openexr_api.cpp

Modified: trunk/blender/source/blender/imbuf/intern/openexr/openexr_api.cpp
===================================================================
--- trunk/blender/source/blender/imbuf/intern/openexr/openexr_api.cpp	2010-07-12 13:35:00 UTC (rev 30227)
+++ trunk/blender/source/blender/imbuf/intern/openexr/openexr_api.cpp	2010-07-12 14:54:05 UTC (rev 30228)
@@ -229,29 +229,44 @@
 											sizeof(float), sizeof(float) * -width));
 		if(ibuf->rect_float) {
 			float *from;
-			
-			for (int i = ibuf->y-1; i >= 0; i--) 
-			{
-				from= ibuf->rect_float + channels*i*width;
-				
-				for (int j = ibuf->x; j > 0; j--) 
+
+			if(ibuf->profile == IB_PROFILE_LINEAR_RGB) {
+				for (int i = ibuf->y-1; i >= 0; i--)
 				{
-					to->r = from[0];
-					to->g = from[1];
-					to->b = from[2];
-					to->a = (channels >= 4)? from[3]: 1.0f;
-					to++; from += 4;
+					from= ibuf->rect_float + channels*i*width;
+
+					for (int j = ibuf->x; j > 0; j--)
+					{
+						to->r = from[0];
+						to->g = from[1];
+						to->b = from[2];
+						to->a = (channels >= 4)? from[3]: 1.0f;
+						to++; from += 4;
+					}
 				}
 			}
+			else {
+				for (int i = ibuf->y-1; i >= 0; i--)
+				{
+					from= ibuf->rect_float + channels*i*width;
+
+					for (int j = ibuf->x; j > 0; j--)
+					{
+						to->r = srgb_to_linearrgb(from[0]);
+						to->g = srgb_to_linearrgb(from[1]);
+						to->b = srgb_to_linearrgb(from[2]);
+						to->a = (channels >= 4)? from[3]: 1.0f;
+						to++; from += 4;
+					}
+				}
+			}
 		}
 		else {
 			unsigned char *from;
 
-			if(ibuf->profile != IB_PROFILE_NONE) {
+			if(ibuf->profile == IB_PROFILE_LINEAR_RGB) {
 				for (int i = ibuf->y-1; i >= 0; i--)
 				{
-					from= (unsigned char *)ibuf->rect + channels*i*width;
-
 					for (int j = ibuf->x; j > 0; j--)
 					{
 						to->r = (float)(from[0])/255.0;
@@ -265,8 +280,6 @@
 			else {
 				for (int i = ibuf->y-1; i >= 0; i--)
 				{
-					from= (unsigned char *)ibuf->rect + channels*i*width;
-
 					for (int j = ibuf->x; j > 0; j--)
 					{
 						to->r = srgb_to_linearrgb((float)from[0] / 255.0);





More information about the Bf-blender-cvs mailing list