Before anything, sorry for reviving an old thread like this.
I've implemented a saveToMemory function and it has worked quite well for me.
I've been thinking of making a PR regarding this change, but first I need to know two things:
- Would this be a good idea?
- What syntax should be used for this?
In regards to the syntax, I've written something like:
bool sf::Image::saveToMemory(const std::string& format, std::vector<sf::Uint8>& buffer);
To be used as:
sf::Image image;
//fill the image with data
...
std::vector<sf::Uint8> buffer;
image.saveToMemory("png", buffer);
While this is perfectly functional, I feel like this API is very inconsistent with the rest of SFML. What is the general opinion about passing the buffer as a parameter? Also, should the format be determined using an enum? I'd usually go for that, but I wanted to be at least a bit consistent with the saveToFile API.