CLIPBOARDIMAGE (function): 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
No edit summary |
No edit summary |
||
(7 intermediate revisions by 2 users not shown) | |||
Line 10: | Line 10: | ||
* When the paste operation is successful, {{Parameter|newImageHandle&}} will be < -1. Handle values of -1 or 0 indicate that there wasn't an image in the clipboard or that the format wasn't accepted. | * When the paste operation is successful, {{Parameter|newImageHandle&}} will be < -1. Handle values of -1 or 0 indicate that there wasn't an image in the clipboard or that the format wasn't accepted. | ||
* Use [[_FREEIMAGE]] to free the memory used by {{Parameter|newImageHandle&}} when it's no longer needed by your program. | * Use [[_FREEIMAGE]] to free the memory used by {{Parameter|newImageHandle&}} when it's no longer needed by your program. | ||
== | {{PageAvailability}} | ||
* ''' | <!-- QB64 = a version or none, QBPE = a version or all, Platforms = yes or no --> | ||
<gallery widths="48px" heights="48px" mode="nolines"> | |||
File:Qb64.png|'''v1.2''' | |||
File:Qbpe.png|'''all''' | |||
File:Apix.png | |||
File:Win.png|'''yes''' | |||
File:Lnx.png|'''yes''' | |||
File:Osx.png|'''yes''' | |||
</gallery> | |||
<!-- additional availability notes go below here --> | |||
* Available for ''macOS'' and ''Linux'' since '''QB64-PE v3.13.0''' | |||
{{PageExamples}} | {{PageExamples}} | ||
;Example: Monitoring the clipboard for new images copied from other programs: | |||
{{CodeStart}}{{Cl|SCREEN}} {{Cl|_NEWIMAGE}}(800, 600, 32) | {{CodeStart}} | ||
{{Cl|SCREEN}} {{Cl|_NEWIMAGE}}({{Text|800|#F580B1}}, {{Text|600|#F580B1}}, {{Text|32|#F580B1}}) | |||
{{Cl|DO}} | {{Cl|DO}} | ||
{{Cl|CLS}} | {{Cl|CLS}} | ||
{{Cl|COLOR}} {{Cl|_RGB32}}(177, 177, 177) | {{Cl|COLOR}} {{Cl|_RGB32}}({{Text|177|#F580B1}}, {{Text|177|#F580B1}}, {{Text|177|#F580B1}}) | ||
{{Cl|PRINT}} "Monitoring clipboard..." | {{Cl|PRINT}} {{Text|<nowiki>"Monitoring clipboard..."</nowiki>|#FFB100}} | ||
{{Cl|IF}} img& < -1 {{Cl|THEN}} _FREEIMAGE img& | {{Cl|IF}} img& < {{Text|-1|#F580B1}} {{Cl|THEN}} {{Cl|_FREEIMAGE}} img& | ||
img& = {{Cl|_CLIPBOARDIMAGE}} | img& = {{Cl|_CLIPBOARDIMAGE (function)|_CLIPBOARDIMAGE}} | ||
IF img& < -1 THEN | {{Cl|IF}} img& < {{Text|-1|#F580B1}} {{Cl|THEN}} | ||
{{Cl|PRINT}} "Image found:" | {{Cl|PRINT}} {{Text|<nowiki>"Image found:"</nowiki>|#FFB100}} | ||
{{Cl|COLOR}} _RGB32(255, 255, 255) | {{Cl|COLOR}} {{Cl|_RGB32}}({{Text|255|#F580B1}}, {{Text|255|#F580B1}}, {{Text|255|#F580B1}}) | ||
{{Cl|PRINT}} "Width :"; {{Cl|_WIDTH (function)|_WIDTH}}(img&) | {{Cl|PRINT}} {{Text|<nowiki>"Width :"</nowiki>|#FFB100}}; {{Cl|_WIDTH (function)|_WIDTH}}(img&) | ||
{{Cl|PRINT}} "Height:"; {{Cl | {{Cl|PRINT}} {{Text|<nowiki>"Height:"</nowiki>|#FFB100}}; {{Cl|_HEIGHT}}(img&) | ||
w = {{Cl|_WIDTH (function)|_WIDTH}} / 2 - {{Cl|_WIDTH (function)|_WIDTH}}(img&) / 2 | w = {{Cl|_WIDTH (function)|_WIDTH}} / {{Text|2|#F580B1}} - {{Cl|_WIDTH (function)|_WIDTH}}(img&) / {{Text|2|#F580B1}} | ||
IF w < 0 THEN w = 0 | {{Cl|IF}} w < {{Text|0|#F580B1}} {{Cl|THEN}} w = {{Text|0|#F580B1}} | ||
{{Cl|_PUTIMAGE}} (w, {{Cl|CSRLIN}} * {{Cl|_FONTHEIGHT}}), img& | {{Cl|_PUTIMAGE}} (w, {{Cl|CSRLIN}} * {{Cl|_FONTHEIGHT}}), img& | ||
ELSE | {{Cl|ELSE}} | ||
PRINT "No image found." | {{Cl|PRINT}} {{Text|<nowiki>"No image found."</nowiki>|#FFB100}} | ||
END IF | {{Cl|END IF}} | ||
{{Cl|_DISPLAY}} | {{Cl|_DISPLAY}} | ||
{{Cl|_LIMIT}} 10 | {{Cl|_LIMIT}} {{Text|10|#F580B1}} | ||
{{Cl|LOOP}} | {{Cl|LOOP}} | ||
{{CodeEnd}} | {{CodeEnd}} | ||
{{ | {{Small|Example by Fellippe Heitor}} | ||
{{PageSeeAlso}} | {{PageSeeAlso}} | ||
* [[_CLIPBOARDIMAGE]] {{ | * [[_CLIPBOARDIMAGE]] {{Text|(statement - used to copy an image to the clipboard)}} | ||
* [[_CLIPBOARD$]], [[_CLIPBOARD$ ( | * [[_CLIPBOARD$]], [[_CLIPBOARD$ (function)]] {{Text|(used to copy/paste text)}} | ||
{{PageNavigation}} | {{PageNavigation}} |
Latest revision as of 15:01, 6 April 2024
The _CLIPBOARDIMAGE function pastes an image from the clipboard into a new 32-bit image in memory.
Syntax
- newImageHandle& = _CLIPBOARDIMAGE
Description
- When the paste operation is successful, newImageHandle& will be < -1. Handle values of -1 or 0 indicate that there wasn't an image in the clipboard or that the format wasn't accepted.
- Use _FREEIMAGE to free the memory used by newImageHandle& when it's no longer needed by your program.
Availability
- Available for macOS and Linux since QB64-PE v3.13.0
Examples
- Example
- Monitoring the clipboard for new images copied from other programs:
SCREEN _NEWIMAGE(800, 600, 32) DO CLS COLOR _RGB32(177, 177, 177) PRINT "Monitoring clipboard..." IF img& < -1 THEN _FREEIMAGE img& img& = _CLIPBOARDIMAGE IF img& < -1 THEN PRINT "Image found:" COLOR _RGB32(255, 255, 255) PRINT "Width :"; _WIDTH(img&) PRINT "Height:"; _HEIGHT(img&) w = _WIDTH / 2 - _WIDTH(img&) / 2 IF w < 0 THEN w = 0 _PUTIMAGE (w, CSRLIN * _FONTHEIGHT), img& ELSE PRINT "No image found." END IF _DISPLAY _LIMIT 10 LOOP |
See also
- _CLIPBOARDIMAGE (statement - used to copy an image to the clipboard)
- _CLIPBOARD$, _CLIPBOARD$ (function) (used to copy/paste text)