From QB64 Wiki
Jump to navigation Jump to search

The _SCREENIMAGE function stores the current desktop image or a portion of it and returns an image handle.


imageHandle& = _SCREENIMAGE(column1, row1, column2, row2)]


  • imageHandle& is the handle to the new image in memory that will contain the desktop screenshot.
  • The optional screen column and row positions can be used to get only a portion of the desktop image.
  • The desktop image or partial image is always a 32-bit image.
  • The current screen resolution or width-to-height aspect ratio can be obtained with _DESKTOPWIDTH and _DESKTOPHEIGHT.
  • Can be used to take screenshots of the desktop or used with _PRINTIMAGE to print them.
  • It is important to free unused or uneeded image handles with _FREEIMAGE to prevent memory overflow errors.
  • Keyword not Supported in Linux or MAC versions


Example: Determining the present screen resolution of user's PC for a screensaver program.

desktop& = _SCREENIMAGE MaxScreenX& = _WIDTH(desktop&) MaxScreenY& = _HEIGHT(desktop&) _FREEIMAGE desktop& 'free image after measuring screen(it is not displayed) SCREEN _NEWIMAGE(MaxScreenX&, MaxScreenY&, 256) 'program window is sized to fit _SCREENMOVE _MIDDLE

Sample code to save images to disk

See also

Keyword Reference - Alphabetical
Keyword Reference - By Usage
Main Wiki Page