Code archives/User Libs/Clipboard Image functions
This code has been declared by its author to be Public Domain code.
Download source code
| |||||
I recently wrote functions to copy/paste FreeImage bitmaps to/from the clipboard, so i thought i would do the same for Blitz3D images. They're a bit slower than the FreeImage functions, because they use read/writepixelfast. You need a file named "User32.decls" in your "userlibs" folder with these. .lib "User32.dll" ; Clipboard Functions Api_CloseClipboard%():"CloseClipboard" Api_EmptyClipboard%():"EmptyClipboard" Api_GetClipboardData%(uFormat):"GetClipboardData" Api_IsClipboardFormatAvailable%(format):"IsClipboardFormatAvailable" Api_OpenClipboard%(hwnd):"OpenClipboard" Api_SetClipboardData%(uFormat,hData):"SetClipboardData"And a file named "Kernel32.decls" in your "userlibs" folder with these. | |||||
.lib "Kernel32.dll" ; Memory Management Functions Api_GlobalAlloc%(uFlags,dwBytes):"GlobalAlloc" Api_GlobalLock%(hMem):"GlobalLock" Api_GlobalUnlock%(hMem):"GlobalUnlock" Api_RtlCopyMemory(Destination,Source*,Length):"RtlMoveMemory" Api_RtlMoveMemory(Destination*,Source,Length):"RtlMoveMemory" |
Comments
| ||
So here is an example using the CopyImageToClipboard function. This only creates 24-bit bitmaps. |
| ||
And here is an example using the PasteImageFromClipboard function. This will convert from 1/4/8-bit as well as 16/24/32-bit bitmaps. |
| ||
This is really good, Thank you for sharing just what I have been looking for in a long while. |
| ||
Wow, this seems pretty interesting... I too have been wondering how to read/write ANY data from the clipboard in blitz for a very long time! So with this you can copy an image section/selection in M.S. Paint and then draw it into a graphics buffer in your Blitz program? |
Code Archives Forum