Hi guys. I haven't turned to you all for help in quite a while, but you're always so helpful when I do. Anyway, if anyone can help I will very much appreciate it.
I have essentially built a level editor to create large maps for a game. I'd like to compile a whole map into one image so I can edit it in photoshop (my artist takes the "skeletons" I create in the editor and then fills them in. Like color-by-numbers).
I've compiled a few maps by manually moving the screen, taking a screenshot, then pasting it into paint and fitting all the screenshots together. Needless to say, this is a huge pain in the ass. So, I'd like to convince my program to do it for me. Here's my code:
void SaveLoad::saveLevelImage(std::string fileName)
{
// Loop through and capture each section of the level.
for(int viewX = 0; viewX < _editor->_mapWidth; viewX += 1920)
{
for(int viewY = 0; viewY < _editor->_mapHeight; viewY += 1080)
{
std::stringstream path;
path << "levels/" << fileName << "/map/" << fileName << viewX << "." << viewY << ".png";
sf::Image screenToSave;
screenToSave = _editor->renderWindow()->capture();
screenToSave.saveToFile(path.str());
_editor->_contentView.move(0, 1080);
}
// After completing a column, return the window back to the top.
_editor->_contentView.setCenter(_editor->_contentView.getCenter().x, 540);
// Move over to the next row and start over.
_editor->_contentView.move(1920, 0);
}
}
When I run the code, the expected files appear in the directory I specified, but they're all blank. I don't know if SFML simply can't handle my request to capture the screen and save it so many times so quickly or what.
I was thinking I'd later use a python script to actually combine the images into one, but if I can't get this part to work, then that's not going to be useful. However, if anyone has any thoughts about combining both steps into one, that would be awesome as well.
Thank you!