hex conversion to binary files
Hi all,
I'm working on a project that requires me to produce .bmp files from data that produced by another program that I'm working on. The other program is working fine.
I have hex values defined as shown
bfType1 = 0x42; // char
bfType2 = 0x4D; // char
bfSize = 0x00000000; //long
bfReserved1 = 0x0000; //short
bfReserved2 = 0x0000; //short
bfOffBits = 0x36; //long
biSize = 0x28; //long
biWidth = 0x0000000A; //long
biHeight = 0x0000000A; //long
biPlanes = 0x0001; //short
biBitCount = 0x0018; //short
biCompression = 0x00000000; //long
biSizeImage = 0x00000000; //long
biXPelsPerMeter = 0x00000000; //long
biYPelsPerMeter = 0x00000000; //long
biClrUsed = 0x00000000; //long
biClrImportant = 0x00000000; //long
I'm trying to write these to a file and the output is wrong. The first two char's are fine. My output code is
ofstream fout("helloworld.bmp",ios::binary);
fout << bfType1 << bfType2 << bfSize << bfReserved1 << bfReserved2 << bfOffBits << bfSize
<< biWidth << biHeight << biPlanes << biBitCount << biCompression << biSizeImage
<< biXPelsPerMeter << biYPelsPerMeter << biClrUsed << biClrImportant ;
and the actual output I am getting (in ascii) is
BM0005401010124000000
Any auggestions? My source for the header info is from a Delphi mnaual, which doesn't look like (to someone who's never touched delphi and is new to c++) it has to use any modifiers to convert from hex into binary.
|