ENIGMA Forums

Sharing is caring => Tips, Tutorials, Examples => Topic started by: hpg678 on May 17, 2019, 07:19:18 am

Title: Screen Save Screen-shot code snippet
Post by: hpg678 on May 17, 2019, 07:19:18 am
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

Code: [Select]

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.


(https://enigma-dev.org/forums/x-special/nautilus-clipboard copy file:///home/patrick/Downloads/output_k58MGv.gif)


Title: Re: Screen Save Screen-shot code snippet
Post by: Goombert on May 17, 2019, 04: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
Title: Re: Screen Save Screen-shot code snippet
Post by: Goombert on May 17, 2019, 07:02:12 pm
Ok the libpng/flipped saving is now fixed, just wait for it to be reviewed.
https://github.com/enigma-dev/enigma-dev/pull/1728