bonjour

j'ai trouvé ce code dans une application de chargement d'une image bmp en C
mais le problem j'arrive pas à comprendre ca sert à qoi le bourrage ici
qlq peut m'explique en détail merci infiniment
aussi si c'est possible de m'explique la fonction writefile avec ses argument surtout le nombre 14 :WriteFile(fichier,&fileheader,14,&dummy,NULL);


/*---------------------------------*/
//Enregistre un fichier bmp24 bits
/*---------------------------------*/
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
BOOL SaveBmp24(char *path,PIXEL *data,int width,int height)
{
	BITMAPFILEHEADER	fileheader;
	BITMAPINFOHEADER	infoheader;
	HANDLE				fichier;
	DWORD				dummy;
	int					size;
	int					bourrage = 0;
	int					i,j,k;
	char				*ima = NULL;

	fichier = CreateFile(path,
						 GENERIC_WRITE,
						 FILE_SHARE_READ,
						 NULL,
						 CREATE_ALWAYS,
						 FILE_ATTRIBUTE_NORMAL,
						 NULL);
	if (fichier == INVALID_HANDLE_VALUE)
		return FALSE;

	fileheader.bfType = 0x4D42;	//"bm"
	fileheader.bfSize = 54 + width*height*3;
	fileheader.bfReserved2 = 0;
	fileheader.bfReserved1 = 0;
	fileheader.bfOffBits = 54;

	infoheader.biSize = sizeof(BITMAPINFOHEADER);
	infoheader.biWidth = width;
	infoheader.biHeight = height;
	infoheader.biPlanes = 1;
	infoheader.biBitCount = 24;
	infoheader.biCompression = 0;
	infoheader.biSizeImage = width*height;
	infoheader.biXPelsPerMeter = 0;
	infoheader.biYPelsPerMeter = 0;
	infoheader.biClrImportant = 0;
	infoheader.biClrUsed = 0;

	while ((3*width+bourrage) % 4 != 0)	//calcul du nb de bits de bourrage (3 car 24bits = 3octs)
		bourrage++;

	size = width*height;

	ima = new char[size*3+bourrage*height];
	if (ima == NULL)
	{
		CloseHandle(fichier);
		return FALSE;
	}
	
	for(i=0;i<height;i++)
	{
		for(j=0;j<width;j++)
		{
			ima[i*(3*width+bourrage)+3*j]		= data[(height-i-1)*width+j].b;
			ima[i*(3*width+bourrage)+3*j+1]	= data[(height-i-1)*width+j].g;
			ima[i*(3*width+bourrage)+3*j+2]	= data[(height-i-1)*width+j].r;
		}
		for(k=1;k<bourrage;k++)
			ima[i*(3*width+bourrage)+3*j+k] = 0;
	}