SFML community forums

Help => Graphics => Topic started by: TheGoldenFyre on April 16, 2016, 10:40:24 am

Title: Question about sf::Image
Post by: TheGoldenFyre on April 16, 2016, 10:40:24 am
Is there a way to export an sf::Image as a .png (or any other image format)?
Title: Re: Question about sf::Image
Post by: Laurent on April 16, 2016, 10:58:06 am
Is there a way to make users read the doc before asking trivial questions? :P
Title: Re: Question about sf::Image
Post by: Carlos Augusto Br Cpp on May 29, 2016, 04:06:30 am
Hey bro!!! Take in mind that to do this you have to create an texture fisrt to use like an (lets suppose ;D) an mask to an blank face..so..suppose that you want to create an texture to an sprite called "ship" (ship.png for example)..
you create the Texture:
// Ship texture
sf::Texture ship_texture;
ship_texture.loadFromFile("ship.png");

// Define the ship sprite
sf::Sprite ship_sprite;

// Set the texture for the sprite
ship_sprite.setTexture(ship_texture);

// So...after you create the game loop you can put
window.clear();

// Draw the sprite
window.draw(ship_sprite);

window.display();

// And you have your image on screen!
 

I hope that this helps...good luck on your programming road..and do the best that you can do.. :)
Title: Re: Question about sf::Image
Post by: nicox11 on May 30, 2016, 09:35:40 am
Yes you can :

http://www.sfml-dev.org/documentation/2.3.2/classsf_1_1Image.php#aec0ed16b67df7b512aaa5c53388ba14e