44 lines
969 B
C
44 lines
969 B
C
|
#include <stdio.h>
|
||
|
#include <stdlib.h>
|
||
|
#include <graph.h>
|
||
|
|
||
|
int main(int argc, char const *argv[])
|
||
|
{
|
||
|
FILE* f;
|
||
|
f = fopen("image.pgm","r");
|
||
|
int i, j, cas;
|
||
|
int largeur, hauteur;
|
||
|
couleur c;
|
||
|
|
||
|
fread(&largeur,3,1,f);
|
||
|
fread(&hauteur,3,1,f);
|
||
|
|
||
|
printf("%d\n",largeur);
|
||
|
printf("%d\n",hauteur);
|
||
|
|
||
|
InitialiserGraphique();
|
||
|
CreerFenetre(10, 10, largeur, hauteur);
|
||
|
fseek(f,largeur/hauteur,SEEK_CUR);
|
||
|
for(i=0;i<largeur;i++){
|
||
|
for(j=0;j<hauteur;j++){
|
||
|
fread(&cas,sizeof(int),1,f);
|
||
|
if(cas == 3){
|
||
|
if(i>= 8 || i<= 36){
|
||
|
if(j>= 10 || j<= 40){
|
||
|
c = CouleurParNom("white");
|
||
|
DessinerPixel(i, j);
|
||
|
}
|
||
|
}
|
||
|
}else{
|
||
|
fread(&c,sizeof(unsigned long),1,f);
|
||
|
ChoisirCouleurDessin(c);
|
||
|
DessinerPixel(i, j);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}
|
||
|
Touche();
|
||
|
FermerGraphique();
|
||
|
fclose(f);
|
||
|
return 0;
|
||
|
}
|