1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
| #include <stdio.h>
#include <stdlib.h>
#include <string.h> /*strcat*/
#define DEBUG
typedef unsigned char uc;
typedef unsigned int ui;
typedef unsigned short us;
typedef struct{
uc Magic[2]; /*magic number*/
ui FileSize[4];/*taille total du fichier*/
us Reserved0[2];/*champ réservé*/
us Reserved1[2] ;/*champ réservé*/
ui Offset[4];/*offset de l'image*/
}enteteInfo;
typedef struct{
ui Size[4];/*taille de l'en tete de l'image*/
ui Width[4];/*nbr colonnes*/
ui Height[4];/*nbr lignes*/
us Planes[2];/*nombre de plan*/
us Count[2];/*profondeur de codage de l'image*/
ui Compr[4];/*methode de compression*/
ui SizeIm[4];/*taille total de l'image*/
ui Xpels[4];/*résolution horizontal*/
ui Xypels[4];/*résolution vertical*/
ui ClrUsed[4];/*nombre de couleur palette*/
ui ClrImp[4];/*nombre de couleur importante*/
}entetestruct;
void lire(void);
enteteInfo a;
entetestruct b;
int main (){
char nomFichier[]="";
FILE* f;
printf("Entrez le nom de l'image \n");
scanf("%s%*c",nomFichier);
strcat(nomFichier,".bmp");
#ifdef DEBUG
printf("\nnom de l'image avec l'extention : %s\n",nomFichier);
scanf("%*c");
#endif
f=fopen(nomFichier,"r");
if (f==NULL){
printf("ouverture impossible de %s\n",nomFichier);
scanf("%*c");
exit(0);
}
fread(&a, sizeof(a), 1, f);
fread(&b, sizeof(b), 1, f);
printf("signature : %c%c\n",a.Magic[0],a.Magic[1]);
printf("taille total du fichier : %d \nOffset : %i\n",a.FileSize,a.Offset);
printf("taille de l'entete de l'image : %d\n",b.Size);
printf("nombre de colonne : %d \nombre de lignes : %d\n",b.Width,b.Height);
printf("Planes : %hd\n",b.Planes);
printf("count : %hd\n",b.Count);
printf("Compression : %d\n",b.Compr);
printf("taille total de l'image image : %d\n",b.SizeIm);
printf("résolution horizontal : %hd\n",b.Xpels);
printf("résolution : %hd\n",b.Xypels);
fclose(f);
#ifdef DEBUG
printf("\nfichier close");
scanf("%*c");
#endif
return (0);
#ifdef DEBUG
printf("fin du programme");
scanf("%*c");
#endif
} |
Partager