Putting an image on the clipboard

by Richard Russell, March 2012

Putting an image on the clipboard is straightforward:

        cx% = 0
        cy% = 0
        hbitmap% = FNloadimage(pic$, cx%, cy%, 0)
        SYS "OpenClipboard", @hwnd%
        SYS "EmptyClipboard"
        SYS "SetClipboardData", CF_BITMAP, hbitmap%
        SYS "CloseClipboard"

Here pic$ is the full path and filename to the image file (which can be a BMP, EMF, GIF, ICO, JPEG or WMF). If you want to support a wider range of formats (including PNG and TIFF) then call FNloadimagegdip or FNloadimagegdip2 rather than FNloadimage.