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
| #include <stdio.h>
typedef struct BMP_FILE_FORMAT
{
char magic[2];
}BMP_FILE_FORMAT;
typedef struct BMP_FILE_HEADER
{
int size;
int reserved0;
int reserved1;
int offset; // the offset, i.e. starting address, of the byte where the bitmap data can be found.
}BMP_FILE_HEADER;
typedef struct BMP_DETAILED_INFO
{
int width;
int height;
int header_size;
short n_planes;//the number of color planes being used. Must be set to 1.
short bits_p_p;//the number of bits per pixel, which is the color depth of the image. Typical values are 1, 4, 8, 16, 24 and 32.
int compress_type;
int image_size;// the image size. This is the size of the raw bitmap data (see below), and should not be confused with the file size.
int h_res; // the horizontal resolution of the image. (pixel per meter, signed integer)
int v_res;
int n_colors; //the number of colors in the color palette, or 0 to default to 2^n.
int n_imp_colors;// the number of important colors used, or 0 when every color is important; generally ignored.
}BMP_DETAILED_INFO;
void Chargement();
BMP_FILE_FORMAT FORMAT;
BMP_FILE_HEADER HEADER;
BMP_DETAILED_INFO INFO;
int main()
{
Chargement();
return 0;
}
void Chargement()
{
FILE *f;
//int K;
f=fopen("imagedt.bmp","rb");
fread(&FORMAT,sizeof(BMP_FILE_FORMAT),1,f);
fread(&HEADER,sizeof(BMP_FILE_HEADER),1,f);
fread(&INFO,sizeof(BMP_DETAILED_INFO),1,f);
printf("--> Format de l'image : %c%c \n\n ",FORMAT.magic[0],FORMAT.magic[1]);
printf("--> Taille du fichier : %d Octets\n\n",HEADER.size);
printf("--> Offset : %d\n\n",HEADER.offset);
printf("--> Header size : %d \n\n",INFO.header_size);
printf("--> Largeur : %d \n\n",INFO.width);
printf("--> Hauteur : %d \n\n",INFO.height);
printf("--> Taille d'image pure : %d \n\n",INFO.image_size);
fclose(f);
/* K=sizeof(HEADER)+sizeof(FORMAT)+sizeof(INFO);
printf("K= %d",K);*/
} |
Partager