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
|
#include <stdio.h>
#include <stdlib.h>
#include <dos.h>
#include <mem.h>
/* Définition des types de variables : */
typedef unsigned char byte; /* */
typedef unsigned short word; /* 0xF */
typedef unsigned long dword; /* 0xFF */
/* Définition de la structure d'un header de fichier BMP */
typedef struct _BMP_HEAD {
word Type; /*File type. Set to "BM".*/
dword Size; /*Size in BYTES of the file.*/
dword Reserved; /*Reserved. Set to zero.*/
dword Offset; /*Offset to the data.*/
dword headerSize; /*Size of rest of header. Set to 40.*/
dword Width; /*Width of bitmap in pixels.*/
dword Height; /*Height of bitmap in pixels.*/
word Planes; /*Number of Planes. Set to 1.*/
word BitsPerPixel; /*Number of bits per pixel.*/
dword Compression; /*Compression. Usually set to 0.*/
dword SizeImage; /*Size in bytes of the bitmap.*/
dword XPixelsPerMeter; /*Horizontal pixels per meter.*/
dword YPixelsPerMeter; /*Vertical pixels per meter.*/
dword ColorsUsed; /*Number of colors used.*/
dword ColorsImportant; /*Number of "important" colors.*/
} BMP_HEAD ;
/* Pointeur sur la mémoire vidéo VGA 13H */
byte *VGA=(byte *) MK_FP(0xA000,0);
void load_bmp(char *file,BITMAP *b)
{
FILE *fp;
/* open the file */
if ((fp = fopen(file,"rb")) == NULL)
{
printf("Erreur l'ors de l'ouverture du fichier %s.\n",file);
exit(1);
}
fread(&b,sizeof(BMP_HEAD), 0, fp);
/*cette ligne est un genre de test pour verifier la bonne marche du chargement du header avant de continuer le codage */
printf("variables : \n type :%s\n Width :%d\n Height :%d\n", b.Type, b.Width, b.Height);
}
int main()
{
BMP_HEAD bmp;
load_bmp("rocket.bmp",&bmp);
getch();
} |
Partager