[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [33355] trunk/blender/source/blender: Bugfix #21385

Ton Roosendaal ton at blender.org
Sat Nov 27 20:33:41 CET 2010


Revision: 33355
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=33355
Author:   ton
Date:     2010-11-27 20:33:40 +0100 (Sat, 27 Nov 2010)

Log Message:
-----------
Bugfix #21385

Blender MultiLayer openEXR files now save with correct scanline order.
Code also provides backward compatibility. Also thanks to Troy Sobotka!

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

Modified: trunk/blender/source/blender/blenkernel/BKE_blender.h
===================================================================
--- trunk/blender/source/blender/blenkernel/BKE_blender.h	2010-11-27 19:18:13 UTC (rev 33354)
+++ trunk/blender/source/blender/blenkernel/BKE_blender.h	2010-11-27 19:33:40 UTC (rev 33355)
@@ -45,7 +45,7 @@
 struct Main;
 
 #define BLENDER_VERSION			255
-#define BLENDER_SUBVERSION		0
+#define BLENDER_SUBVERSION		1
 
 #define BLENDER_MINVERSION		250
 #define BLENDER_MINSUBVERSION	0

Modified: trunk/blender/source/blender/imbuf/intern/openexr/openexr_api.cpp
===================================================================
--- trunk/blender/source/blender/imbuf/intern/openexr/openexr_api.cpp	2010-11-27 19:18:13 UTC (rev 33354)
+++ trunk/blender/source/blender/imbuf/intern/openexr/openexr_api.cpp	2010-11-27 19:33:40 UTC (rev 33355)
@@ -342,6 +342,7 @@
 		int ystride = - xstride*width;
 		float *rect[4] = {NULL, NULL, NULL, NULL};
 
+		/* last scanline, stride negative */
 		rect[0]= ibuf->rect_float + channels*(height-1)*width;
 		rect[1]= rect[0]+1;
 		rect[2]= rect[0]+2;
@@ -498,7 +499,7 @@
 	// openexr_header_metadata(&header, ibuf); // no imbuf. cant write
 	/* header.lineOrder() = DECREASING_Y; this crashes in windows for file read! */
 	
-	header.insert ("BlenderMultiChannel", StringAttribute ("Blender V2.43 and newer"));
+	header.insert ("BlenderMultiChannel", StringAttribute ("Blender V2.55.1 and newer"));
 	
 	data->ofile = new OutputFile(filename, header);
 }
@@ -615,9 +616,13 @@
 	ExrChannel *echan;
 	
 	if(data->channels.first) {
-		for(echan= (ExrChannel *)data->channels.first; echan; echan= echan->next)
-			frameBuffer.insert (echan->name, Slice (FLOAT,  (char *)echan->rect, 
-													echan->xstride*sizeof(float), echan->ystride*sizeof(float)));
+		for(echan= (ExrChannel *)data->channels.first; echan; echan= echan->next) {
+			/* last scanline, stride negative */
+			float *rect = echan->rect + echan->xstride*(data->height-1)*data->width;
+			
+			frameBuffer.insert (echan->name, Slice (FLOAT,  (char *)rect, 
+													echan->xstride*sizeof(float), -echan->ystride*sizeof(float)));
+		}
 		
 		data->ofile->setFrameBuffer (frameBuffer);
 		try {
@@ -638,11 +643,20 @@
 	FrameBuffer frameBuffer;
 	ExrChannel *echan;
 	
+	/* check if exr was saved with previous versions of blender which flipped images */
+	const StringAttribute *ta = data->ifile->header().findTypedAttribute <StringAttribute> ("BlenderMultiChannel");
+	short flip = (ta && strncmp(ta->value().c_str(), "Blender V2.43", 13)==0); /* 'previous multilayer attribute, flipped */
+	
 	for(echan= (ExrChannel *)data->channels.first; echan; echan= echan->next) {
-		/* no datawindow correction needed */
-		if(echan->rect)
-			frameBuffer.insert (echan->name, Slice (FLOAT,  (char *)echan->rect, 
-												echan->xstride*sizeof(float), echan->ystride*sizeof(float)));
+		
+		if(echan->rect) {
+			if(flip)
+				frameBuffer.insert (echan->name, Slice (FLOAT,  (char *)echan->rect, 
+											echan->xstride*sizeof(float), echan->ystride*sizeof(float)));
+			else
+				frameBuffer.insert (echan->name, Slice (FLOAT,  (char *)(echan->rect + echan->xstride*(data->height-1)*data->width), 
+											echan->xstride*sizeof(float), -echan->ystride*sizeof(float)));
+		}
 		else 
 			printf("warning, channel with no rect set %s\n", echan->name);
 	}





More information about the Bf-blender-cvs mailing list