Skip to content
Extraits de code Groupes Projets
Valider 3a0553f8 rédigé par Lénaïc DURAND's avatar Lénaïc DURAND
Parcourir les fichiers

ombres++

parent dd14dbe8
Branches
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
Fichier supprimé
...@@ -50,6 +50,7 @@ Ray3f Scene::source() const ...@@ -50,6 +50,7 @@ Ray3f Scene::source() const
void Scene::render(int width, int height, int nb_pixel_row, int nb_pixel_col, int nb_shapes, char* filename) void Scene::render(int width, int height, int nb_pixel_row, int nb_pixel_col, int nb_shapes, char* filename)
{ {
/*--------------------------------Copié de la doc de libpng-------------------------------------*/
FILE *f = fopen(filename, "wb"); FILE *f = fopen(filename, "wb");
if (!f) throw "Echec de la création du fichier"; if (!f) throw "Echec de la création du fichier";
...@@ -69,6 +70,8 @@ void Scene::render(int width, int height, int nb_pixel_row, int nb_pixel_col, in ...@@ -69,6 +70,8 @@ void Scene::render(int width, int height, int nb_pixel_row, int nb_pixel_col, in
} }
png_init_io(png_ptr, f); png_init_io(png_ptr, f);
/*----------------------------------------------------------------------------------------------*/
//Set header //Set header
png_set_IHDR(png_ptr, info_ptr, nb_pixel_row, nb_pixel_col, 8, PNG_COLOR_TYPE_RGB, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE); png_set_IHDR(png_ptr, info_ptr, nb_pixel_row, nb_pixel_col, 8, PNG_COLOR_TYPE_RGB, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
...@@ -81,17 +84,17 @@ void Scene::render(int width, int height, int nb_pixel_row, int nb_pixel_col, in ...@@ -81,17 +84,17 @@ void Scene::render(int width, int height, int nb_pixel_row, int nb_pixel_col, in
png_write_info(png_ptr, info_ptr); png_write_info(png_ptr, info_ptr);
//Mémoire allouée pour une ligne de pixels (rgb => 3 bytes par pixel) //Mémoire allouée pour une ligne de pixels (rgb => 3 bytes par pixel)
png_bytep row = (png_bytep) png_malloc(png_ptr, 3*nb_pixel_row*sizeof(png_byte)); png_bytep row = (png_bytep) png_malloc(png_ptr, 3*nb_pixel_row*sizeof(png_byte));
float pw = (float) width / (float) nb_pixel_col; float pw = (float) width / (float) nb_pixel_col; //largeur d'un pixel
float ph = (float) height / (float) nb_pixel_row; float ph = (float) height / (float) nb_pixel_row; //hauteur d'un pixel
float min_dist; float min_dist;
float hit_dist; float hit_dist;
for (int i=nb_pixel_col-1; i>=0; i--) for (int i=nb_pixel_col-1; i>=0; i--) //on remplit l'image par le bas à droite
//for (int i=0; i<nb_pixel_col; i++)
{ {
for (int j=0; j<nb_pixel_row; j++) for (int j=0; j<nb_pixel_row; j++)
{ {
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter