diff --git a/main b/main deleted file mode 100755 index 6ad67cf004206bccd23ad8c37507d2b455d5b442..0000000000000000000000000000000000000000 Binary files a/main and /dev/null differ diff --git a/scene.cpp b/scene.cpp index f10504ce2b52e0c7beec09c9f7aa5172ef830250..f87bfbf1f35d11aef06af5513595debb54adbfed 100644 --- a/scene.cpp +++ b/scene.cpp @@ -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) { + /*--------------------------------Copié de la doc de libpng-------------------------------------*/ FILE *f = fopen(filename, "wb"); 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 } png_init_io(png_ptr, f); + /*----------------------------------------------------------------------------------------------*/ + //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); @@ -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); + //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)); - float pw = (float) width / (float) nb_pixel_col; - float ph = (float) height / (float) nb_pixel_row; + float pw = (float) width / (float) nb_pixel_col; //largeur d'un pixel + float ph = (float) height / (float) nb_pixel_row; //hauteur d'un pixel float min_dist; float hit_dist; - for (int i=nb_pixel_col-1; i>=0; i--) - //for (int i=0; i<nb_pixel_col; i++) + for (int i=nb_pixel_col-1; i>=0; i--) //on remplit l'image par le bas à droite { for (int j=0; j<nb_pixel_row; j++) {