Skip to content
Snippets Groups Projects
Commit a5d1f0c2 authored by jorge.leitemac's avatar jorge.leitemac :juggling_tone5:
Browse files

fonction read ok

parent d3708647
No related branches found
No related tags found
No related merge requests found
......@@ -10,13 +10,11 @@ pgm_error pmg_read_from_file(pgm *p, char *filename)
exit(0);
}
//type
char type[3];
//Taille de l'image
int hauteur = 0;
int largeur = 0;
//Niveau de gris maximal
int niveauGris = 0;
char type[3]; //type
int hauteur = 0; //Taille de l'image
int largeur = 0;
int niveauGris = 0; //Niveau de gris maximal
fscanf(f, "%s %d %d %d", type, &hauteur, &largeur, &niveauGris );
......@@ -25,7 +23,6 @@ pgm_error pmg_read_from_file(pgm *p, char *filename)
if(taille <= 0){
return failure;
}
p->max = niveauGris;
//tableau pour init depuis matrix
......@@ -36,19 +33,18 @@ pgm_error pmg_read_from_file(pgm *p, char *filename)
fread(&pixels[i], sizeof(uint8_t), 1, f);
}
//ok pas detecté, a regler
if (matrix_init_from_array(&p->pixels, hauteur, largeur, pixels) != ok) {
//Convertit le tableau pixels et l'affecte au pgm
if (matrix_init_from_array(&p->pixels, hauteur, largeur, pixels) != OK) {
return failure;
}
printf("Type : %s\n", type);
printf("Hauteur : %d\n", hauteur);
printf("Hauteur : %d\n", largeur);
printf("nvGris : %d\n", niveauGris);
fclose(f);
return success;
}
\ No newline at end of file
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment