Pages: 1
Author Topic: Screen Save Screen-shot code snippet  (35,775 Views)
Offline (Unknown gender) hpg678

Member
Joined: Mar 2017
Posts: 283
View profile
Posted on: May 17, 2019, 12:19:18 PM
Here's a little work-a-round using code to save a screen-shot of your games.


in an object in the Create Event, create a variable 'num = 0'; This is to track auto-numbering of the generic filename to save the screen-shot.


In the 'keyboard_released_letter' event e.g i used "S" place this code



var screenshot = background_create_from_screen(0,0, window_get_width(), window_get_height(), false, true);
fname = get_save_filename("Save screenshot (*.png)|*.png", "screenshot"+string(num)+".png");
if (fname != "")
{
   //background_save(screenshot, "screenshot_"+(string(num))+".png"); //use this for automatic screenshot numbering
   background_save(screenshot, fname); //use if you want to give custom filename
   num += 1; // you can leave this
}
else
{
   show_error("File not saved!", false)
}



Please note that in Linux you would need to have a Dialog API set to either Zenity or Kdialog for it to work.





Offline (Unknown gender) Goombert

Developer
Joined: Jan 2013
Posts: 2,991
View profile
Reply #1 Posted on: May 17, 2019, 09:54:21 PM
Thanks for the tip hugar! If I may ask, is this suggestion a result of issues you faced with [snip]screen_save[/snip] function which is implemented? I actually ran onto this myself working on the screen cleanup which will be merged soon. If you save as bmp instead of png, it may fix it. I will send a pull request to fix it after the cleanup is finished.
https://github.com/enigma-dev/enigma-dev/pull/1725
Offline (Unknown gender) Goombert

Developer
Joined: Jan 2013
Posts: 2,991
View profile
Reply #2 Posted on: May 18, 2019, 12:02:12 AM
Ok the libpng/flipped saving is now fixed, just wait for it to be reviewed.
https://github.com/enigma-dev/enigma-dev/pull/1728
Pages: 1