src/raytracermodule.cc
branchpyrit
changeset 89 fcf1487b398b
parent 84 6f7fe14782c2
child 90 f6a72eb99631
--- a/src/raytracermodule.cc	Mon Apr 28 11:44:11 2008 +0200
+++ b/src/raytracermodule.cc	Tue Apr 29 13:56:29 2008 +0200
@@ -801,19 +801,10 @@
 		return Py_None;
 	}
 
-	// convert data to char
 	printf("[pyrit] Converting image data (float to char)\n");
-	chardata = (unsigned char *) malloc(w*h*3);
-	Float *d = data;
-	for (unsigned char *c = chardata; c != chardata + w*h*3; c++, d++) {
-		if (*d > 1.0)
-			*c = 255;
-		else
-			*c = (unsigned char)(*d * 255.0);
-	}
-	free(data);
+	chardata = sampler.getPixmap().getCharData();
 	o = Py_BuildValue("s#", chardata, w*h*3);
-	free(chardata);
+	delete[] chardata;
 	printf("[pyrit] Done.\n");
 	return o;
 }