Bonjour,
Pour un projet de traitement d'images, j'ai réalisé toutes mes fonctions pour des images au format bitmap.
Cependant, je dois maintenant passer au format pgm et cela me pose problème. J'ai bien regardé l'en-tête de ce format pgm mais je n'ai pas réussi à acquérir l'image dans un tableau à deux dimensions.
Pouvez-vous m'aider?
Voici ma fonction d'acquisition pour un format bitmap:
void init(PIXEL_RVB BitMap[taille][taille],RESOLUTION *resolution, char Nom[taille])
{
FILE *pFichier=NULL;
U32 lig,col;
if((pFichier=fopen(Nom,"r+b"))==NULL) //tant que pFichier est nulle, attendre 100 ms
{
printf("\nPB ouverture du fichier\n\n"); //faire une attente
}
else
{
fseek(pFichier,18,SEEK_SET);
fread(&resolution->largeur,sizeof(U32),1,pFichier);
fread(&resolution->hauteur,sizeof(32),1,pFichier);
// printf("Hauteur=%lu\n",resolution->hauteur);
// printf("largeur=%lu\n",resolution->largeur);
fseek(pFichier,56,SEEK_SET);
for(lig=0;lig<resolution->hauteur;lig++)
{
for(col=0;col<resolution->largeur;col++)
{
fread(&BitMap[lig][col],sizeof(PIXEL_RVB),1,pFichier);
}col=0;
}lig=0;
fclose(pFichier);
}
}
Que faut-il changer pour un format pgm?
Merci et à bientôt.
Partager