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)?