The first was already suggested:
b = colorPlane[4*index];
g = colorPlane[4*index+1];
r = colorPlane[4*index+2];
Some more improvements for color and compatiblity are here:
sf.seekg(bmheader.dataOffset);
imgData = new BYTE[bmInfo.imageSize];
sf.read((char*)imgData,bmInfo.imageSize);
and finally to be independent from width this is important:
unsigned long stride = ((((bmInfo.width * bmInfo.bitCount) + 31) & ~31) >> 3);
for(int j=0; j<bmInfo.heigh; j++)
for(int i=0;i<bmInfo.width; i++)
{
index = (unsigned long)imgData[stride*j + i];
...