[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [19001] trunk/blender/source/blender/imbuf /intern/radiance_hdr.c: fix for [#17972] Saving/ Loading Radiance HDR changes colors

Campbell Barton ideasman42 at gmail.com
Tue Feb 17 05:33:15 CET 2009


Revision: 19001
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=19001
Author:   campbellbarton
Date:     2009-02-17 05:32:49 +0100 (Tue, 17 Feb 2009)

Log Message:
-----------
fix for  [#17972] Saving/Loading Radiance HDR changes colors
removed HDR loop that loaded 8bit color channels (which was incorrect)
and added a call to IMB_rect_from_float at the end.

This also means that char buffers wont be created if they are not needed.

Modified Paths:
--------------
    trunk/blender/source/blender/imbuf/intern/radiance_hdr.c

Modified: trunk/blender/source/blender/imbuf/intern/radiance_hdr.c
===================================================================
--- trunk/blender/source/blender/imbuf/intern/radiance_hdr.c	2009-02-17 04:11:20 UTC (rev 19000)
+++ trunk/blender/source/blender/imbuf/intern/radiance_hdr.c	2009-02-17 04:32:49 UTC (rev 19001)
@@ -180,7 +180,6 @@
 	int width=0, height=0;
 	int x, y;
 	unsigned char* ptr;
-	unsigned char* rect;
 	char oriY[80], oriX[80];
 
 	if (imb_is_a_hdr((void*)mem))
@@ -201,7 +200,7 @@
 			ptr++;
 
 			if (flags & IB_test) ibuf = IMB_allocImBuf(width, height, 32, 0, 0);
-			else ibuf = IMB_allocImBuf(width, height, 32, IB_rect|IB_rectfloat, 0);
+			else ibuf = IMB_allocImBuf(width, height, 32, (flags & IB_rect)|IB_rectfloat, 0);
 
 			if (ibuf==NULL) return NULL;
 			ibuf->ftype = RADHDR;
@@ -211,7 +210,6 @@
 
 			/* read in and decode the actual data */
 			sline = (RGBE*)MEM_mallocN(sizeof(RGBE)*width, "radhdr_read_tmpscan");
-			rect = (unsigned char*)ibuf->rect;
 			rect_float = (float *)ibuf->rect_float;
 			
 			for (y=0;y<height;y++) {
@@ -228,19 +226,15 @@
 					*rect_float++ = fcol[GRN];
 					*rect_float++ = fcol[BLU];
 					*rect_float++ = 1.0f;
-					/* Also old oldstyle for the rest of blender which is not using floats yet */
-					// e: changed to simpler tonemapping, previous code was rather slow (is this actually still relevant at all?)
-					fcol[RED] = fcol[RED]/(1.f + fcol[RED]);
-					fcol[GRN] = fcol[GRN]/(1.f + fcol[GRN]);
-					fcol[BLU] = fcol[BLU]/(1.f + fcol[BLU]);
-					*rect++ = (unsigned char)((fcol[RED] < 0.f) ? 0 : ((fcol[RED] > 1.f) ? 255 : (255.f*fcol[RED])));
-					*rect++ = (unsigned char)((fcol[GRN] < 0.f) ? 0 : ((fcol[GRN] > 1.f) ? 255 : (255.f*fcol[GRN])));
-					*rect++ = (unsigned char)((fcol[BLU] < 0.f) ? 0 : ((fcol[BLU] > 1.f) ? 255 : (255.f*fcol[BLU])));
-					*rect++ = 255;
 				}
 			}
 			MEM_freeN(sline);
 			if (oriY[0]=='-') IMB_flipy(ibuf);
+			
+			if (flags & IB_rect) {
+				IMB_rect_from_float(ibuf);
+			}
+			
 			return ibuf;
 		}
 		//else printf("Data not found!\n");




More information about the Bf-blender-cvs mailing list