Can someoene help with loadFromMemory() ? I mean how to implement and use it.
I tried as a test:
sf::Image *image = new sf::Image();
image->loadFromFile("file.png"); //works
sf::Image image2;
image2.loadFromMemory(image, sizeof(*image)); //doesn't work
Doesn't work...
I think that the first argument is supposed to point to array of RGBA pixels not image, image can give you the pointer to pixels it's storing, and second argument, size, is 4*amount of pixels.
So if you want to load from one image into other like that you should do:
sf::Image *image new sf::Image();
image->loadFromFile("file.png");
sf::Image image2;
image2.loadFromMemory(image->getPixelsPtr(),image->getSize().x*image->getSize().y*4);
Altho it's somewhat insane to dynamically allocate first image.
getPixelsPtr returns read only pointer but I'm not sure if image2 will make a deep copy for itself so you might want to mess with first image, delete it, ect. and see if the second one still works, or wait for Laurent to clarify that. :)