SFML community forums

Help => Graphics => Topic started by: TheEnigmist on May 12, 2011, 11:53:22 pm

Title: How to take screenshots
Post by: TheEnigmist on May 12, 2011, 11:53:22 pm
I'm looking for comand to take a screenshot with SFML 2.0
The App.Capture of 1.6 doesn't work in 2.0 and i didn't find the good comand to do it.
I need to make a menĂ¹ with last frame of the game under it.
So i want to do this
Take screen-> take it in memory -> use the comande Image.LoadFromMemory -> show it under menu interface.
Can i do it? :)
Title: How to take screenshots
Post by: Nexus on May 13, 2011, 01:07:38 am
sf::Image::CopyScreen() (http://www.sfml-dev.org/documentation/2.0/classsf_1_1Image.php#a35d840e67a4303e92e1449c94833faf6)
Title: How to take screenshots
Post by: TheEnigmist on May 13, 2011, 11:50:49 am
Thanks man ;)
Title: How to take screenshots
Post by: TheEnigmist on May 13, 2011, 01:10:21 pm
A question... i want to save my screenshot by numbers
Ex: screen001,screen002 etc.
I made this code but i don't know how to put into SaveToFile()_
Code: [Select]

char screen[50];
int numScreen=4;
sprintf (screen, "%03d", numScreen);


So if i do cout << screen; i get 004 etc.
Can you help me? :)
Title: How to take screenshots
Post by: Fred_FS on May 13, 2011, 01:26:51 pm
If you're programming c++, you should use c++ ;).

I recommend std::stringstream to you. It should look like this:
Code: [Select]

std::stringstream filename;
filename << "screenshots/screenshot_" << screenshot_num_ << ".png";
Image.SaveToFile( filename.str() );
Title: How to take screenshots
Post by: TheEnigmist on May 13, 2011, 01:34:39 pm
Quote from: "Fred_FS"
If you're programming c++, you should use c++ ;).

I recommend std::stringstream to you. It should look like this:
Code: [Select]

std::stringstream filename;
filename << "screenshots/screenshot_" << screenshot_num_ << ".png";
Image.SaveToFile( filename.str() );

You... you are a f*cking genius LOL
Thx a lot :)
Now i've to lern how to avoid FPS Overlay benn captured by game :)
Title: How to take screenshots
Post by: Walker on May 13, 2011, 02:33:55 pm
There's probably a better way to do it, but the first thing that comes to mind is ...

Code: [Select]
If screenshot button pressed
    takeScreenshot = true

//Drawing stuff
if !takeScreenshot
    draw FPS

blah blah

if takeScreenshot
    take screenshot


I am rather tired so sorry if this is impossible/stupid/doesn't work :)
Title: How to take screenshots
Post by: TheEnigmist on May 13, 2011, 03:28:23 pm
Quote from: "Walker"
There's probably a better way to do it, but the first thing that comes to mind is ...

Code: [Select]
If screenshot button pressed
    takeScreenshot = true

//Drawing stuff
if !takeScreenshot
    draw FPS

blah blah

if takeScreenshot
    take screenshot


I am rather tired so sorry if this is impossible/stupid/doesn't work :)


The problem is that FPS shown on screen is not from game... is from a third-party program (Fraps/Play Claw etc). I don't know why it capture this overlay too, but i can't find a solution to isolate it
Title: How to take screenshots
Post by: Fred_FS on May 13, 2011, 03:37:53 pm
It is called "screenshot". Hence it captures what's on the screen. And the overly is on the screen, hence it is captured ;).
The easiest way would probably be not to use these FPS-applications, if you want to create a screenshot.
Title: How to take screenshots
Post by: TheEnigmist on May 13, 2011, 04:54:44 pm
Quote from: "Fred_FS"
It is called "screenshot". Hence it captures what's on the screen. And the overly is on the screen, hence it is captured ;).
The easiest way would probably be not to use these FPS-applications, if you want to create a screenshot.


Uhm but there are some games that doesn't capture FPS :(
(I've just take some screenshots in Portal 2)
Title: How to take screenshots
Post by: Groogy on May 14, 2011, 01:42:07 am
They probably write some windows specific code to omit that. Not something you can do purely trough SFML. I recommend instead that you have your own FPS overlay built into the application. And any other debug information you might need.
Title: How to take screenshots
Post by: TheEnigmist on May 14, 2011, 10:17:29 am
Quote from: "Groogy"
They probably write some windows specific code to omit that. Not something you can do purely trough SFML. I recommend instead that you have your own FPS overlay built into the application. And any other debug information you might need.


Ah ok :(
Thanks for infos!