CLIPBOARDIMAGE: Difference between revisions

From QB64 Phoenix Edition Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 20: Line 20:
{{PageExamples}}
{{PageExamples}}
''Example:'' Create a sample image and copy it to the clipboard:
''Example:'' Create a sample image and copy it to the clipboard:
{{CodeStart}}{{Cl|SCREEN}} {{Cl|_NEWIMAGE}}(800, 600, 32)
{{CodeStart}}
{{Cl|SCREEN}} {{Cl|_NEWIMAGE}}({{Text|800|#F580B1}}, {{Text|600|#F580B1}}, {{Text|32|#F580B1}})


'Create image in memory:
{{Text|<nowiki>'Create image in memory:</nowiki>|#919191}}
canvas& = {{Cl|_NEWIMAGE}}(300, 200, 32)
canvas& = {{Cl|_NEWIMAGE}}({{Text|300|#F580B1}}, {{Text|200|#F580B1}}, {{Text|32|#F580B1}})
{{Cl|_DEST}} canvas&
{{Cl|_DEST}} canvas&


'Draw some random rectangles:
{{Text|<nowiki>'Draw some random rectangles:</nowiki>|#919191}}
{{Cl|RANDOMIZE}} {{Cl|TIMER (function)|TIMER}}
{{Cl|RANDOMIZE}} {{Cl|TIMER (function)|TIMER}}
{{Cl|FOR}} i = 1 {{Cl|TO}} 100
{{Cl|FOR}} i = {{Text|1|#F580B1}} {{Cl|TO}} {{Text|100|#F580B1}}
     {{Cl|LINE}} (-100 + RND * _WIDTH, -100 + RND * _HEIGHT)-STEP(RND * 150, RND * 150), _RGB(RND * 255, RND * 255, RND * 255), BF
     {{Cl|LINE}} ({{Text|-100|#F580B1}} + {{Cl|RND}} * {{Cl|_WIDTH (function)|_WIDTH}}, {{Text|-100|#F580B1}} + {{Cl|RND}} * {{Cl|_HEIGHT}})-{{Cl|STEP}}({{Cl|RND}} * {{Text|150|#F580B1}}, {{Cl|RND}} * {{Text|150|#F580B1}}), {{Cl|_RGB}}({{Cl|RND}} * {{Text|255|#F580B1}}, {{Cl|RND}} * {{Text|255|#F580B1}}, {{Cl|RND}} * {{Text|255|#F580B1}}), BF
{{Cl|NEXT}}
{{Cl|NEXT}}
LINE (0, 0)-(_WIDTH - 1, _HEIGHT - 1), _RGB(255, 255, 255), B
{{Cl|LINE}} ({{Text|0|#F580B1}}, {{Text|0|#F580B1}})-({{Cl|_WIDTH (function)|_WIDTH}} - {{Text|1|#F580B1}}, {{Cl|_HEIGHT}} - {{Text|1|#F580B1}}), {{Cl|_RGB}}({{Text|255|#F580B1}}, {{Text|255|#F580B1}}, {{Text|255|#F580B1}}), B
{{Cl|COLOR}} {{Cl|_RGB}}(0, 0, 0), _RGB(255, 255, 255)
{{Cl|COLOR}} {{Cl|_RGB}}({{Text|0|#F580B1}}, {{Text|0|#F580B1}}, {{Text|0|#F580B1}}), {{Cl|_RGB}}({{Text|255|#F580B1}}, {{Text|255|#F580B1}}, {{Text|255|#F580B1}})
m$ = " Hello, world! "
m$ = {{Text|<nowiki>" Hello, world! "</nowiki>|#FFB100}}
{{Cl|_PRINTSTRING}} (_WIDTH / 2 - _PRINTWIDTH(m$) / 2, _HEIGHT / 2 - _FONTHEIGHT / 2), m$
{{Cl|_PRINTSTRING}} ({{Cl|_WIDTH (function)|_WIDTH}} / {{Text|2|#F580B1}} - {{Cl|_PRINTWIDTH}}(m$) / {{Text|2|#F580B1}}, {{Cl|_HEIGHT}} / {{Text|2|#F580B1}} - {{Cl|_FONTHEIGHT}} / {{Text|2|#F580B1}}), m$


'Show the image:
{{Text|<nowiki>'Show the image:</nowiki>|#919191}}
{{Cl|_DEST}} 0
{{Cl|_DEST}} {{Text|0|#F580B1}}
{{Cl|_PUTIMAGE}} (_WIDTH / 2 - _WIDTH(canvas&) / 2, _HEIGHT / 2 - _HEIGHT(canvas&) / 2), canvas&
{{Cl|_PUTIMAGE}} ({{Cl|_WIDTH (function)|_WIDTH}} / {{Text|2|#F580B1}} - {{Cl|_WIDTH (function)|_WIDTH}}(canvas&) / {{Text|2|#F580B1}}, {{Cl|_HEIGHT}} / {{Text|2|#F580B1}} - {{Cl|_HEIGHT}}(canvas&) / {{Text|2|#F580B1}}), canvas&
{{Cl|PRINT}} "Image generated."
{{Cl|PRINT}} {{Text|<nowiki>"Image generated."</nowiki>|#FFB100}}


'Copy to the clipboard:
{{Text|<nowiki>'Copy to the clipboard:</nowiki>|#919191}}
{{Cl|_CLIPBOARDIMAGE}} = canvas&
{{Cl|_CLIPBOARDIMAGE}} = canvas&


PRINT "Image copied to clipboard."
{{Cl|PRINT}} {{Text|<nowiki>"Image copied to clipboard."</nowiki>|#FFB100}}
{{CodeEnd}}
{{CodeEnd}}
{{Small|Code by Fellippe Heitor}}
{{Small|Code by Fellippe Heitor}}

Revision as of 21:23, 20 March 2023

The _CLIPBOARDIMAGE statement copies a valid QB64 image to the clipboard.


Syntax

_CLIPBOARDIMAGE = existingImageHandle&


Description


Availability

  • Build 20170906/64 onward.


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."
Code by Fellippe Heitor


See also



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