Flopp
Flopp

Reputation: 1947

Copy image data to clipboard on windows

On Linux, I can easily copy an image as PNG data to the clipboard using the clipboard command, which can then be pasted into a graphics program (e.g. GIMP):

set w 300
set h 200
set i [image create photo -width $w -height $h]
$i put blue -to 0 0 $w $h

clipboard clear
clipboard append -type image/png -- [$i data -format png]

image delete $i

However on Windows, this doesn't work; i.e. the clipboard command succeeds, but I cannot paste the image anywhere; also, clipboard monitors (such as http://freeclipboardviewer.com/) don't show any copied content.

Is there anything wrong with -type image/png? Should I use a different -type parameter or even a different data format (e.g. BMP, JPEG)?

Can this be done with "native" Tcl/Tk commands (without using twapi as suggested in https://wiki.tcl-lang.org/page/Copy+image+to+and+from+the+Windows+clipboard)?

Upvotes: 1

Views: 2136

Answers (1)

L. Alejandro M.
L. Alejandro M.

Reputation: 629

Short anwser. You can't. I guess you best/only option is twapi.

The tk's clipboard command on Windows works for text only. As you can read in the source file of windows's clipboard there are not options for images, just for text.

Upvotes: 1

Related Questions