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

  1. package require Tk 8.6
  2.  
  3. # copy the image at http://www.ljplus.ru/img4/a/_/a_bdpyr/nukemushroom.jpg
  4. # or any other big image
  5.  
  6. set img [image create photo]
  7.  
  8. if {[catch {selection get -type TARGETS} targets] == 0
  9. && "image/png" in $targets } {
  10. set data [selection get -type "image/png"]
  11.  
  12. # should print "Index: 262143 : 0xNN0xNN"
  13. puts "Index: [set idx [lsearch $data 0x580xf7]] : [lindex $data $idx]"
  14.  
  15. $img configure -data [binary format c* $data]
  16. }