How to take a screenshot from BlitzMax 2D fullscreen game

I know that many people’s mind has been troubled how to take a screenshot from a BlitzMax 2D fullscreen game.

I’m not familiar with any program, that can take capture from a BlitzMax fullscreen game (with programs that capture video from a game this is possible, though). Usually I use free IrfanView to take screen captures, but in BlitzMax games I do it inside the code. I share here my little code I use:

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.