Posted to tcl by emiliano at Sat Jul 18 17:49:41 GMT 2009view pretty

package require Tk 8.6

# copy the image at http://www.ljplus.ru/img4/a/_/a_bdpyr/nukemushroom.jpg
# or any other big image

set img [image create photo]

if {[catch {selection get -type TARGETS} targets] == 0 
        && "image/png" in $targets } {
    set data [selection get -type "image/png"]

    # should print "Index: 262143 : 0xNN0xNN"
    puts "Index: [set idx [lsearch $data 0x580xf7]] : [lindex $data $idx]"

    $img configure -data [binary format c* $data]
}