CLIPBOARDIMAGE: Difference between revisions
Jump to navigation
Jump to search
Example by Fellippe Heitor
Navigation:
Main Page with Articles and Tutorials
Keyword Reference - Alphabetical
Keyword Reference - By usage
Report a broken link
(Update availability) |
No edit summary |
||
(One intermediate revision by one other user not shown) | |||
Line 11: | Line 11: | ||
* You can pass [[_SOURCE]], [[_DEST]] or [[_DISPLAY]] to copy the current source, destination or active display pages, as long as they are valid graphic images. | * You can pass [[_SOURCE]], [[_DEST]] or [[_DISPLAY]] to copy the current source, destination or active display pages, as long as they are valid graphic images. | ||
* SCREEN 0 handles (created either with [[_NEWIMAGE]] or passed using _DEST while in a text screen) are not valid and will create an [[ERROR Codes|Illegal Function Call]] or [[ERROR Codes|Invalid Handle]] error. | * SCREEN 0 handles (created either with [[_NEWIMAGE]] or passed using _DEST while in a text screen) are not valid and will create an [[ERROR Codes|Illegal Function Call]] or [[ERROR Codes|Invalid Handle]] error. | ||
Line 17: | Line 16: | ||
<!-- QB64 = a version or none, QBPE = a version or all, Platforms = yes or no --> | <!-- QB64 = a version or none, QBPE = a version or all, Platforms = yes or no --> | ||
<gallery widths="48px" heights="48px" mode="nolines"> | <gallery widths="48px" heights="48px" mode="nolines"> | ||
File:Qb64.png|'''v1. | File:Qb64.png|'''v1.2''' | ||
File:Qbpe.png|'''all''' | File:Qbpe.png|'''all''' | ||
File:Apix.png | File:Apix.png | ||
Line 29: | Line 28: | ||
{{PageExamples}} | {{PageExamples}} | ||
;Example: Create a sample image and copy it to the clipboard: | |||
{{CodeStart}} | {{CodeStart}} | ||
{{Cl|SCREEN}} {{Cl|_NEWIMAGE}}({{Text|800|#F580B1}}, {{Text|600|#F580B1}}, {{Text|32|#F580B1}}) | {{Cl|SCREEN}} {{Cl|_NEWIMAGE}}({{Text|800|#F580B1}}, {{Text|600|#F580B1}}, {{Text|32|#F580B1}}) | ||
Line 57: | Line 56: | ||
{{Cl|PRINT}} {{Text|<nowiki>"Image copied to clipboard."</nowiki>|#FFB100}} | {{Cl|PRINT}} {{Text|<nowiki>"Image copied to clipboard."</nowiki>|#FFB100}} | ||
{{CodeEnd}} | {{CodeEnd}} | ||
{{Small| | {{Small|Example by Fellippe Heitor}} | ||
Latest revision as of 14:58, 6 April 2024
The _CLIPBOARDIMAGE statement copies a valid QB64 image to the clipboard.
Syntax
- _CLIPBOARDIMAGE = existingImageHandle&
Description
- existingImageHandle& is a valid handle to a graphic QB64 image in memory, created with _NEWIMAGE, _LOADIMAGE or _COPYIMAGE.
- You can pass _SOURCE, _DEST or _DISPLAY to copy the current source, destination or active display pages, as long as they are valid graphic images.
- SCREEN 0 handles (created either with _NEWIMAGE or passed using _DEST while in a text screen) are not valid and will create an Illegal Function Call or Invalid Handle error.
Availability
- Available for macOS and Linux since QB64-PE v3.13.0
Examples
- Example
- Create a sample image and copy it to the clipboard:
SCREEN _NEWIMAGE(800, 600, 32) 'Create image in memory: canvas& = _NEWIMAGE(300, 200, 32) _DEST canvas& 'Draw some random rectangles: RANDOMIZE TIMER FOR i = 1 TO 100 LINE (-100 + RND * _WIDTH, -100 + RND * _HEIGHT)-STEP(RND * 150, RND * 150), _RGB(RND * 255, RND * 255, RND * 255), BF NEXT LINE (0, 0)-(_WIDTH - 1, _HEIGHT - 1), _RGB(255, 255, 255), B COLOR _RGB(0, 0, 0), _RGB(255, 255, 255) m$ = " Hello, world! " _PRINTSTRING (_WIDTH / 2 - _PRINTWIDTH(m$) / 2, _HEIGHT / 2 - _FONTHEIGHT / 2), m$ 'Show the image: _DEST 0 _PUTIMAGE (_WIDTH / 2 - _WIDTH(canvas&) / 2, _HEIGHT / 2 - _HEIGHT(canvas&) / 2), canvas& PRINT "Image generated." 'Copy to the clipboard: _CLIPBOARDIMAGE = canvas& PRINT "Image copied to clipboard." |
See also
- _CLIPBOARDIMAGE (function - used to paste an image from the clipboard)
- _CLIPBOARD$, _CLIPBOARD$ (function) (used to copy/paste text)