I've got my heightMapLoad function working the way I want it side from how fast it is. As of now it takes around 30 seconds to load a 2048x2048 greyscale image. Any tips as to how I could improve the speed of this loader..

Code :
bool loadHeightMap(const char* fileName, std::vector<float>& heightMap, 
	std::vector<unsigned int>& index, float tileSize, float maxHeight)
{
	//Load image with SDL
	SDL_Surface* img = SDL_LoadBMP(fileName);
	if(!img)
	{
		std::cout<<"Failed to load " << fileName << "." << std::endl;
		return false;
	}
 
	//Store height values in heights vector.
	std::vector<float> tmp;
	std::vector<std::vector<float>> heights;
	for(int i = 0; i < img->h; i++)
	{
		tmp.clear();
		for(int j = 0; j < img->w; j++)
		{
			Uint32 pixel = ((Uint32*)img->pixels)[i * img->pitch / 4 + j];
			Uint8 r, g, b;
			SDL_GetRGB(pixel, img->format, &r, &g, &b);
 
			tmp.push_back((float)r/255.0);
		}
		heights.push_back(tmp);
	}
 
	//Fill the vertex data and index data.
	for(int z = 0; z < img->h; z++)
	{
		for(int x = 0; x < img->w; x++)
		{
			heightMap.push_back((float)x * tileSize);
			heightMap.push_back((float)heights[x][z] * maxHeight);
			heightMap.push_back((float)z * tileSize);
 
			heightMap.push_back((float)heights[x][z]);
			heightMap.push_back((float)heights[x][z]);
			heightMap.push_back((float)heights[x][z]);
 
 
			if(x < img->w-1 && z < img->h-1)
			{
				int top = z * img->w + x;
				int bottom = (z+1)*img->w + x;
 
				index.push_back(top);
				index.push_back(bottom);
				index.push_back(top+1);
 
				index.push_back(top+1);
				index.push_back(bottom);
				index.push_back(bottom+1);
			}
		}
	}
 
	SDL_FreeSurface(img);
	if(heights.empty())
	{
		std::cout<< "Failed to get height data." << std::endl;
		return false;
	}
	if(index.empty())
	{
		std::cout<< "Failed get index data." << std::endl;
		return false;
	}
	if(heightMap.empty())
	{
		std::cout<< "Failed to get vertex data." << std::endl;
		return false;
	}
	return true;
}

edit: A small question that's been bugging me I just haven't search much for an answer yet... Is there some kind of default max view distance in opengl? I know when I load this 2048x2048 heightmap I cannot see the whole thing as the view is cut out at a far distance.