[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [50996] trunk/blender/source/blender/imbuf /intern/openexr/openexr_api.cpp: Fix #32712: non-multilayer openexr file save for a single channel image would

Brecht Van Lommel brechtvanlommel at pandora.be
Mon Oct 1 22:21:51 CEST 2012


Revision: 50996
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=50996
Author:   blendix
Date:     2012-10-01 20:21:50 +0000 (Mon, 01 Oct 2012)
Log Message:
-----------
Fix #32712: non-multilayer openexr file save for a single channel image would
write wrong colors for float and crash for half-float.

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	2012-10-01 18:31:32 UTC (rev 50995)
+++ trunk/blender/source/blender/imbuf/intern/openexr/openexr_api.cpp	2012-10-01 20:21:50 UTC (rev 50996)
@@ -372,10 +372,10 @@
 
 				for (int j = ibuf->x; j > 0; j--) {
 					to->r = from[0];
-					to->g = from[1];
-					to->b = from[2];
+					to->g = (channels >= 2) ? from[1] : from[0];
+					to->b = (channels >= 3) ? from[2] : from[0];
 					to->a = (channels >= 4) ? from[3] : 1.0f;
-					to++; from += 4;
+					to++; from += channels;
 				}
 			}
 		}
@@ -383,7 +383,7 @@
 			unsigned char *from;
 
 			for (int i = ibuf->y - 1; i >= 0; i--) {
-				from = (unsigned char *)ibuf->rect + channels * i * width;
+				from = (unsigned char *)ibuf->rect + 4 * i * width;
 
 				for (int j = ibuf->x; j > 0; j--) {
 					to->r = srgb_to_linearrgb((float)from[0] / 255.0f);
@@ -448,8 +448,8 @@
 
 		/* last scanline, stride negative */
 		rect[0] = ibuf->rect_float + channels * (height - 1) * width;
-		rect[1] = rect[0] + 1;
-		rect[2] = rect[0] + 2;
+		rect[1] = (channels >= 2) ? rect[0] + 1 : rect[0];
+		rect[2] = (channels >= 3) ? rect[0] + 2 : rect[0];
 		rect[3] = (channels >= 4) ? rect[0] + 3 : rect[0]; /* red as alpha, is this needed since alpha isn't written? */
 
 		frameBuffer.insert("R", Slice(Imf::FLOAT,  (char *)rect[0], xstride, ystride));




More information about the Bf-blender-cvs mailing list