How to capture a screenshot from BlitzMax 2D fullscreen game

It’s of course possible to capture a screenshot from BlitzMax fullscreen game with video capture programs such Fraps. It can be also done with the in the BlitzMax code of the game. Here’s my little code to do it:

SuperStrict

HideMouse

Const JPEG_QUALITY:Int = 90

Graphics 640,480,32,1

Local screenpixmap:TPixmap = CreatePixmap(640,480,PF_RGBA8888)

While Not KeyHit(KEY_ESCAPE)
   Cls

   DrawOval (640 - 32) / 2, (480 - 32) / 2, 32, 32

   If KeyHit(KEY_C) Then
      screenpixmap = GrabPixmap(0,0,640,480)
      SavePixmapJPeg (screenpixamp,"filename.jpg",JPEG_QUALITY)	
   EndIf
 
   Flip
	
Wend
End

One must define a Pixmap to which the screen’s content is grabbed. When the contents are grabbed the pixmap is saved as JPEG picture by name “filename.jpg”.

In this example program the screenshot is taken when key c is pressed and saved as jpeg-file.

%d bloggers like this: