Original Post
I''m trying to load a bitmap into memory without using any MFC or WIN32 functions. I''ve created a structure to hold the header information as follows:
I load the header with this code fragement:
The signature is loaded fine for every bitmap I''ve tested, but after that, all the values in the header are way waaaaay off. I get widths and heights that are completely different for square bitmaps, reports of a compression type of 2594389 (valid values, as far as I know, are only 0, 1, or 2), etc. Anyone see what I''ve done wrong?
---DanMan
struct BITMAPHEADER
{
char signature[2]; //Should be "BM" if the file is a bitmap
int fileSize; //The size of the file in bytes
int reserved; //Should be 0
int dataOffset; //the data offset (in bytes) to the actual bitmap data
int size; //The size of the info header (the next 40 bytes in the file); should always be 40
int width; //The width of the bitmap in pixels
int height; //The height of the bitmap in pixels
short planes; //Should always be 1
short bitCount; //Bits per pixel
int compression; //The compression used, 0 means no compression (only one we care about)
int compressedSize; //The compressed size of the image, 0 if no compression
int xPixelsPerMeter; //Horizontal resoultion in pixels/meter
int yPixelsPerMeter; //Vertical resolution in pixels/meter
int colorsUsed; //The number of colos actually used in the image
int numImptColors; //The number of important colors
};
bitmapFile.open(mapfile,ios::in | ios::binary ); //if the file could not be opened if(!bitmapFile.is_open()) return false; //read the header in bitmapFile.read((char*)&bitmapHeader,sizeof(BITMAPHEADER)); //if an error occured while reading the header if(bitmapFile.fail()) return false;