Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Question about sf::Image  (Read 2500 times)

0 Members and 1 Guest are viewing this topic.

TheGoldenFyre

  • Newbie
  • *
  • Posts: 18
    • View Profile
Question about sf::Image
« 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)?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Question about sf::Image
« Reply #1 on: April 16, 2016, 10:58:06 am »
Is there a way to make users read the doc before asking trivial questions? :P
Laurent Gomila - SFML developer

Carlos Augusto Br Cpp

  • Newbie
  • *
  • Posts: 40
  • Programming is life
    • View Profile
    • Email
Re: Question about sf::Image
« Reply #2 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.. :)

nicox11

  • Jr. Member
  • **
  • Posts: 51
    • View Profile