//allocate raw memory to read in image
if(!AllocateStorage( imageSize ) )
return ;
// Set some of the image parameters.
SetImageHeight(m_bi.bmiHeader.biHeight);
SetImageWidth(m_bi.bmiHeader.biWidth);
SetImageBPP((unsigned char)m_bi.bmiHeader.biBitCount);
//if lower than 16,24,32 bit colour, read in the palette.
if(m_bi.bmiHeader.biBitCount <= 8)
{
// Set the number of colors to the max for the mode (MAX 256).
m_iColoursUsed = 1 << m_bi.bmiHeader.biBitCount;
// Use what is in the file if it is defined.
if(m_bi.bmiHeader.biClrUsed != 0)
m_iColoursUsed = (int)m_bi.bmiHeader.biClrUsed;
// Allocate the space for the palette.
m_pbi = (bmp::BITMAPINFO*)malloc( sizeof(bmp::BITMAPINFO) + (sizeof(bmp::RGBQUAD) * m_iColoursUsed) );
// Copy the header info into the new memory.
memcpy(&m_pbi->bmiHeader, &m_bi.bmiHeader, sizeof(m_bi.bmiHeader));