src/raytracermodule.cc
branchpyrit
changeset 89 fcf1487b398b
parent 84 6f7fe14782c2
child 90 f6a72eb99631
equal deleted inserted replaced
88:f7edb3b90816 89:fcf1487b398b
   799 	if (!data) {
   799 	if (!data) {
   800 		Py_INCREF(Py_None);
   800 		Py_INCREF(Py_None);
   801 		return Py_None;
   801 		return Py_None;
   802 	}
   802 	}
   803 
   803 
   804 	// convert data to char
       
   805 	printf("[pyrit] Converting image data (float to char)\n");
   804 	printf("[pyrit] Converting image data (float to char)\n");
   806 	chardata = (unsigned char *) malloc(w*h*3);
   805 	chardata = sampler.getPixmap().getCharData();
   807 	Float *d = data;
       
   808 	for (unsigned char *c = chardata; c != chardata + w*h*3; c++, d++) {
       
   809 		if (*d > 1.0)
       
   810 			*c = 255;
       
   811 		else
       
   812 			*c = (unsigned char)(*d * 255.0);
       
   813 	}
       
   814 	free(data);
       
   815 	o = Py_BuildValue("s#", chardata, w*h*3);
   806 	o = Py_BuildValue("s#", chardata, w*h*3);
   816 	free(chardata);
   807 	delete[] chardata;
   817 	printf("[pyrit] Done.\n");
   808 	printf("[pyrit] Done.\n");
   818 	return o;
   809 	return o;
   819 }
   810 }
   820 
   811 
   821 static PyObject* Raytracer_setCamera(PyObject* self, PyObject* args)
   812 static PyObject* Raytracer_setCamera(PyObject* self, PyObject* args)