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

Author Topic: sf::Image from list of sf::Shapes?  (Read 1268 times)

0 Members and 1 Guest are viewing this topic.

evil_twinkie

  • Newbie
  • *
  • Posts: 7
    • View Profile
sf::Image from list of sf::Shapes?
« on: June 22, 2011, 12:47:44 am »
Hey everyone.

The project I'm currently working on generates a graph.  It creates an std::vector of sf::Shapes that represent the plots, grid, etc...

I want to be able to export this list of shapes to a file.  I know that Image.SaveToFile can do this with images, but is there a way to combine all of my shapes into one sf::Image?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
sf::Image from list of sf::Shapes?
« Reply #1 on: June 22, 2011, 08:02:22 am »
You must draw them, then save the result to an image (and then to a file). With SFML 2 you can use sf::RenderImage. With SFML 1 you'll have to draw them to a RenderWindow (so they'll be visible).
Laurent Gomila - SFML developer

evil_twinkie

  • Newbie
  • *
  • Posts: 7
    • View Profile
sf::Image from list of sf::Shapes?
« Reply #2 on: June 23, 2011, 01:15:22 am »
Okay that's what I figured.

The graph fills only a part of the RenderWindow when it's drawn, and that's the only thing I want saved to an image file.

Is there a way I can cut down an sf::Image to certain dimensions after calling RederWindow.Capture?  Otherwise, I tried sf::Image.CopyScreen(RW, sf::IntRect) but the screenshot is mirrored.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
sf::Image from list of sf::Shapes?
« Reply #3 on: June 23, 2011, 07:43:45 am »
You can use Image::Copy to extract a region of an image.
Laurent Gomila - SFML developer