Cracking The Bitmap
August 1, 2010 Leave a comment
I thought of looking at how information is stored in the Bitmap format. So I made the following C++ program.
#include<fstream.h>
int main(void)
{
ifstream onfi;
onfi.open("untitled.bmp",ios::nocreate);
while(!onfi.eof())
{
char a;
onfi.read(&a, sizeof(char));
cout<<'\n'<<int(unsigned char(a));
}
return 0;
}
The program simply outputs all the bytes in the file. One byte in one line. After much analysis I found out that the first 2 bytes store “BM”. The next 52 are used to store the various properties of the image (like dimensions). Then the next bytes store the colours if the file is not 24 bit. Then all the pixels are stored in a linear fashion. I won’t give the details of the file here (like which byte stores the width of the file). If you want them contact me. Now I have also made a program which can make .bmp files.