Squarespace’s all-in-one platform gives you everything you need to express yourself creatively online, whether it is with a domain, website, or online store. Get started with your free trial today, and when ready, take 10% off your first purchase with offer code 'EXPERTS'.
BITMAPINFOHEADER ih;
unsigned char *bits;
//load the bitmap
ifstream in(fileName, ios::in | ios::binary);
if(in.fail())
{
bits = NULL;
return;
}
in.read( (unsigned char*)&fh, sizeof(BITMAPFILEHEADER) );
//check for valid bitmap
if( fh.bfType != 'MB' )
{
bits = NULL;
return;
}
in.read( (unsigned char*)&ih, sizeof(BITMAPINFOHEADER) );
int bitsize;
if( (bitsize = ih.biSizeImage) == 0 )
bitsize = (ih.biWidth * ih.biBitCount + 7) /
8 * abs(ih.biHeight);
bits = new unsigned char[(const)bitsize];
in.read( (unsigned char*)bits, bitsize );
}
If you use this code, bits will contain an array of unsigned characters (0-255) containing the BGR values of each bit. 3 bytes per pixel... B then G then R.