Salut,
Quel outil permet de créer une matrice d'une image dans un .H depuis une bmp?
typedef struct{
u32 SizeofHeader; // 40
u32 Width, Height;
u16 Colorplanes; // Usually 1
u16 BitsperPixel; //1, 2, 4, 8, 16, 24, 32
u32 Compression; // 0 for none, 1...
u32 SizeofData; // Not reliable
u32 WidthperMeter, HeightperMeter; // Don't care
u32 NColors, ImportantColors; // Number of colors used, important colors ?
} BMP_Headers;
//La fonction en elle même
void LoadBmpToBuffer(u16 *Buffer, s16 x, s16 y, void *bmp, s16 SWidth){
u8 *temp = (u8*)bmp;
BMP_Headers *Bmpinfo = (BMP_Headers*)(temp+14);
u8 *gfx = temp+54;
u16 *gfx2 = (u16*)(temp+54); // Pour le mode 16 bit...
s32 r, g, b; s16 tempx, tempy;
s16 lx = Bmpinfo->Width; s16 ly = Bmpinfo->Height;
u16 Bits = Bmpinfo->BitsperPixel;
s32 i = 0;
if (Bits > 16){ // Pour 24 et 32 bits
for (tempy = ly-1; tempy > -1; tempy--){
for (tempx = 0; tempx < lx; tempx++){
b = (gfx[i]); i++;
g = (gfx[i]); i++;
r = (gfx[i]); i++;
if (Bits == 32) i++; // On passe le bit alpha
Buffer[x + tempx + ((y + tempy) * SWidth)] = XRGB(r, g, b);
}
while(i&3) i++; // Padding....
}
}
if (Bits == 16){
for (tempy = ly-1; tempy > -1; tempy--){
for (tempx = 0; tempx < lx; tempx++){
b = *gfx2&31;
g = (*gfx2>>5)&31;
r = (*gfx2>>10)&31;
Buffer[x + tempx + ((y + tempy) * SWidth)] = XRGB(r*8, g*8, b*8);
gfx2++; // On passe au pixel suivant
}
s32 temp = (s32)gfx2;
while(temp&3) temp++; // Padding....
gfx2 = (u16*)temp;
}
}
}