SFML community forums
General => Feature requests => Topic started by: gsaurus on February 09, 2010, 01:01:23 pm
-
There is a LoadFromFile, loadFromPixelsPtr and LoadFromMemory.
There is a SaveToFile, GetPixelsPtr, but no "SaveToMemory" method.
I use my own file protocols, saving and loading images along with other data in the same file. I can load them with loadFromMemory, but I can't save them that way. I have to use GetPixelsPtr to send it to a (file) stream, and loadFromPixelsPtr when loading.
But I guess load/save from/to file/memory uses specific image format compression, and so, better than saving the pixels full data.
A SaveToMemory should receive an indication about image format (png, jpg, etc)
I have another question:
- When using LoadFromPixelsPtr, do I have to keep my pointer and free it when the image isn't in use anymore? I would like to just send the pointer to sf::Image and let it take care of it, as I don't need the pointer for anything else (but better would be using the Load & SaveToMemory instead :P)
Thanks,
G
-
There is a LoadFromFile, loadFromPixelsPtr and LoadFromMemory.
There is a SaveToFile, GetPixelsPtr, but no "SaveToMemory" method.
I wouldn't be able to implement this feature at 100%, because not all the underlying libraries I use provide a way to do it. For example, libsndfile looks ok for audio files, but it seems to be impossible with SOIL for image files.
I have another question:
- When using LoadFromPixelsPtr, do I have to keep my pointer and free it when the image isn't in use anymore? I would like to just send the pointer to sf::Image and let it take care of it, as I don't need the pointer for anything else (but better would be using the Load & SaveToMemory instead)
You can do whatever you want with the pointer, sf::Image copies everything that it needs and does not rely on pointers to external data.
-
I see. I needed it just for png format, since it's better for RGBA.
I'll keep saving and loading width, height and pixels pointer then. Using zlib compression over my files should reduce size significantly.
You can do whatever you want with the pointer, sf::Image copies everything that it needs and does not rely on pointers to external data.
Ah, ok thanks. I just free it after loading sf::Image :P