SCREENIMAGE: Difference between revisions

From QB64 Phoenix Edition Wiki
Jump to navigation Jump to search
(Created page with "{{DISPLAYTITLE:_SCREENIMAGE}} The _SCREENIMAGE function stores the current desktop image or a portion of it and returns an image handle. {{PageSyntax}} : {{Parameter|imageHandle&}} = _SCREENIMAGE({{Parameter|column1}}, {{Parameter|row1}}, {{Parameter|column2}}, {{Parameter|row2}})] {{PageDescription}} * {{Parameter|imageHandle&}} is the handle to the new image in memory that will contain the desktop screenshot. * The optional screen {{Parameter|column}} and {...")
 
No edit summary
 
(11 intermediate revisions by 2 users not shown)
Line 4: Line 4:


{{PageSyntax}}
{{PageSyntax}}
: {{Parameter|imageHandle&}} = [[_SCREENIMAGE]]({{Parameter|column1}}, {{Parameter|row1}}, {{Parameter|column2}}, {{Parameter|row2}})]
: {{Parameter|imageHandle&}} = [[_SCREENIMAGE]][({{Parameter|column1}}, {{Parameter|row1}}, {{Parameter|column2}}, {{Parameter|row2}})]




Line 10: Line 10:
* {{Parameter|imageHandle&}} is the handle to the new image in memory that will contain the desktop screenshot.
* {{Parameter|imageHandle&}} is the handle to the new image in memory that will contain the desktop screenshot.
* The optional screen {{Parameter|column}} and {{Parameter|row}} positions can be used to get only a portion of the desktop image.
* The optional screen {{Parameter|column}} and {{Parameter|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 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]].
* 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.
* 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.
* It is important to free unused or uneeded image handles with [[_FREEIMAGE]] to prevent memory overflow errors.
* [[Keywords_currently_not_supported_by_QB64#Keywords_Not_Supported_in_Linux_or_MAC_OSX_versions|Keyword not Supported in Linux or MAC versions]]
* '''[[Keywords currently not supported by QB64#Keywords_not_supported_in_Linux_or_macOS_versions|Keyword not supported in Linux or macOS versions]]'''




Line 24: Line 24:
  MaxScreenY& = {{Cl|_HEIGHT}}(desktop&)
  MaxScreenY& = {{Cl|_HEIGHT}}(desktop&)
  {{Cl|_FREEIMAGE}} desktop& 'free image after measuring screen(it is not displayed)
  {{Cl|_FREEIMAGE}} desktop& 'free image after measuring screen(it is not displayed)
  {{Cl|SCREEN (statement)|SCREEN}} {{Cl|_NEWIMAGE}}(MaxScreenX&, MaxScreenY&, 256) 'program window is sized to fit
  {{Cl|SCREEN}} {{Cl|_NEWIMAGE}}(MaxScreenX&, MaxScreenY&, 256) 'program window is sized to fit
  {{Cl|_SCREENMOVE}} _MIDDLE
  {{Cl|_SCREENMOVE}} _MIDDLE
{{CodeEnd}}
{{CodeEnd}}


 
=== Sample code to save images to disk ===
===Sample code to save images to disk===
* [[SaveImage SUB]]
*[[SAVEIMAGE]]
* [[Program ScreenShots]] (member-contributed program for legacy screen modes)
*[[Program ScreenShots]] (member-contributed program for legacy screen modes)
* [[ThirtyTwoBit SUB]]
* [[ThirtyTwoBit SUB]]
* [[SaveIcon32]]
* [[SaveIcon32]]





Latest revision as of 20:05, 5 January 2024

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


Syntax

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


Description

  • 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 macOS versions


Examples

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



Navigation:
Main Page with Articles and Tutorials
Keyword Reference - Alphabetical
Keyword Reference - By usage
Report a broken link