Skip to content

Commit

Permalink
Create Example - Save png screenshot of window.monkey2
Browse files Browse the repository at this point in the history
  • Loading branch information
Pakz001 committed Nov 19, 2016
1 parent 70e6e17 commit 6ad0b90
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions Example - Save png screenshot of window.monkey2
@@ -0,0 +1,32 @@
#Import "<std>"
#Import "<mojo>"

Using std..
Using mojo..


Class MyWindow Extends Window

Method New()
End method

Method OnRender( canvas:Canvas ) Override
App.RequestRender() ' Activate this method
' Press space to make screenshot.....
If Keyboard.KeyReleased(Key.Space)
Local filename:String=DesktopDir()+"screenshot.png"
Local screenshot:Pixmap = canvas.CopyPixmap(New Recti(0, 0, Width, Height))
SavePixmap(screenshot, filename)
Print "Screenshot saved as : "+filename
End If
' if key escape then quit
If Keyboard.KeyReleased(Key.Escape) Then App.Terminate()
End Method

End Class

Function Main()
New AppInstance
New MyWindow
App.Run()
End Function

0 comments on commit 6ad0b90

Please sign in to comment.