[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [59668] trunk/blender/intern/cycles/render /image.cpp: Fix #36611: cycles issue loading png file with 2 channels.

Brecht Van Lommel brechtvanlommel at pandora.be
Fri Aug 30 19:01:44 CEST 2013


Revision: 59668
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=59668
Author:   blendix
Date:     2013-08-30 17:01:44 +0000 (Fri, 30 Aug 2013)
Log Message:
-----------
Fix #36611: cycles issue loading png file with 2 channels.

Modified Paths:
--------------
    trunk/blender/intern/cycles/render/image.cpp

Modified: trunk/blender/intern/cycles/render/image.cpp
===================================================================
--- trunk/blender/intern/cycles/render/image.cpp	2013-08-30 16:52:54 UTC (rev 59667)
+++ trunk/blender/intern/cycles/render/image.cpp	2013-08-30 17:01:44 UTC (rev 59668)
@@ -307,7 +307,7 @@
 	}
 
 	/* we only handle certain number of components */
-	if(!(components == 1 || components == 3 || components == 4)) {
+	if(!(components >= 1 && components <= 4)) {
 		if(in) {
 			in->close();
 			delete in;
@@ -334,8 +334,16 @@
 		builtin_image_pixels_cb(img->filename, img->builtin_data, pixels);
 	}
 
-	if(components == 3) {
+	if(components == 2) {
 		for(int i = width*height-1; i >= 0; i--) {
+			pixels[i*4+3] = pixels[i*2+1];
+			pixels[i*4+2] = pixels[i*2+0];
+			pixels[i*4+1] = pixels[i*2+0];
+			pixels[i*4+0] = pixels[i*2+0];
+		}
+	}
+	else if(components == 3) {
+		for(int i = width*height-1; i >= 0; i--) {
 			pixels[i*4+3] = 255;
 			pixels[i*4+2] = pixels[i*3+2];
 			pixels[i*4+1] = pixels[i*3+1];
@@ -390,7 +398,7 @@
 		builtin_image_info_cb(img->filename, img->builtin_data, is_float, width, height, components);
 	}
 
-	if(!(components == 1 || components == 3 || components == 4)) {
+	if(!(components >= 1 && components <= 4)) {
 		if(in) {
 			in->close();
 			delete in;
@@ -416,8 +424,16 @@
 		builtin_image_float_pixels_cb(img->filename, img->builtin_data, pixels);
 	}
 
-	if(components == 3) {
+	if(components == 2) {
 		for(int i = width*height-1; i >= 0; i--) {
+			pixels[i*4+3] = pixels[i*2+1];
+			pixels[i*4+2] = pixels[i*2+0];
+			pixels[i*4+1] = pixels[i*2+0];
+			pixels[i*4+0] = pixels[i*2+0];
+		}
+	}
+	else if(components == 3) {
+		for(int i = width*height-1; i >= 0; i--) {
 			pixels[i*4+3] = 1.0f;
 			pixels[i*4+2] = pixels[i*3+2];
 			pixels[i*4+1] = pixels[i*3+1];




More information about the Bf-blender-cvs mailing list