I was doing something similar recently trying to get some destructible terrain happening, although I was reading directly from an image.
for (int x = 0; x < 1024; x++)
{
for (int y = 0; y < 768; y++)
{
if (terrainImage.GetPixel(x, y) == sf::Color::White)//if pixel is white
{
terrainArray[x][y] = 0;//acts as nothing
}
else if (terrainImage.GetPixel(x, y) == sf::Color::Green)
{
terrainArray[x][y] = 1;//acts as normal land
}
else if (terrainImage.GetPixel(x, y) == sf::Color::Black)
{
terrainArray[x][y] = 2;//indestructible pixel
}
}
}
I then later used the array as a reference to build an image/sprite pair that would be displayed. I used this method so I could make each separate area (sky, normal ground and rocks for indestructible bits) look a little more interesting by colouring each pixel semi randomly.
I think that should help. Feel free to ask for more if you want.