I solved this problem as shown below:
ULONG ulPixelDataSize = Height * Width * 3;
RGBQUAD* pRGB = new RGBQUAD[nNumColors];// Color table filled in pRGB.
BYTE* pbyPixelData = new BYTE[width * height];// Pixel data filled in pbyPixelData.
BYTE byNewSamplesPerPixel = 3;
BYTE* pbyRgbBuffer = new BYTE[ulPixelDataSize];
for( int nBufferIndex = 0; nBufferIndex < Height * Width; ++nBufferIndex )
{
int nColouIndex = pbyPixelData[nBufferIndex];
memcpy( pbyRgbBuffer + ( nBufferIndex * byNewSamplesPerPixel ), reinterpret_cast<BYTE*>( &( pRGB[nColouIndex] )), byNewSamplesPerPixel );
}
Thank you for the support and valuable comments.
It will be better if this problem can be resolved with higher performance than this one.