I have wrote a program to read from a bmp.
the bmp itself has 40x40 pixels with 8bit(says windows explorer)
my code:
int main()
{
FILE *f;
BITMAPINFOHEADER header;
f=fopen("apply.a.bmp","r");
fread(&header,sizeof(header),1,f);
int size = header.biBitCount; //in byte
int i = 0;
void *pixel = malloc(size);
while(feof(f) == 0)
{
i++;
fread(&pixel,sizeof(pixel),1,f);
cout << (int)pixel << endl;
};
cout << i << " pixels red" << endl;
fclose(f);
system("pause");
return 0;
}
but after i red all the pixels my program prints "373 pixels red". thats not correct(40x40 = 1600)
whats my fault?
thank you in advance