Witam, zdaję sobie sprawę, że temat opisywany jest wszędzie i jest pełno artykułów odnośnie tego lecz ciągle nie mogę zrozumieć jednej rzeczy.
mam taki program
void read(char *FileName)
{
FILE *file = fopen(FileName,"rb");
unsigned char info[150];
int i=0;
if(file)
{
while(i<54)
{
fscanf(file,"%c",&info[i]);
i++;
}
printf("\n\n");
while(i<150)
{
fscanf(file,"%c",&info[i]);
i++;
}
printf("\n");
fclose(file);
}else
perror("Error");
printf("Identify: %c%c\n",info[0],info[1]);
printf("File Size = %d\n",info[2]+info[3]*256+info[4]*65536);
printf("Table is in: %d\n",info[10]+info[11]*256*info[12]*65536+info[13]);
printf("The size of this header: %d\n",info[14]+info[15]*256*info[16]*65536+info[17]);
printf("The bitmap width in pixel: %d\n",info[18]+info[19]*256+info[20]*65536+info[21]);
printf("The bitmap height in pixels: %d\n",info[22]+info[23]*256+info[24]*65536+info[25]);
printf("The color depth: %d\n",info[28]+info[29]);
printf("The compression method: %d\n",info[30]+info[31]*256+info[32]*65536+info[32]);
printf("\n**************Color Table**********\n");
printf("biClrImportant: %d\n",info[50]);
printf("Table of color: %d\n",info[46]+info[47]*256+info[48]*65536+info[49]);
printf("biClrImportant: %d\n",info[50]);
int a=54,b;
while(a<100)
{
for(b=0;b<4;b++)
{
printf("%d ",info[a]);
a++;
}
printf("\n");
}
}
Ogólnie sprawa jest prosta, odczytuje nagłówek i wszystko jest ok.
Problem rozpoczyna się przy odczycie palety kolorów,odczytuje B G R + alpha i dostaje coś takiego:
0 0 0 0
0 0 128 0
0 128 0 0
0 128 128 0
128 0 0 0
128 0 128 0
128 128 0 0
192 192 192 0
192 220 192 0
240 202 166 0
0 32 64 0
0 32 96 0
Jak zinterpretować te wyniki ? czym jest pierwsze 4 bajty od adresu 54 ?? Moja bitmapa to czerwona kostka 10x10.