icoview

Richard Suchenwirth 2004-10-01 - Here's a little tool for inspecting Windows .ico files, which often contain several variants of an icon at different sizes and color depths. Lazily I let a text widget do geometry management for this UI, including the Load button, the images, and some text comments.

WikiDbImage icoview.gif

Img does not allow us to write such .ico files, however. For this, the ico package is recommended - and it also can read/write from/to .exe and .dll files. See icoview2.

 package require Img
 
 proc loadIco w {
    set fn [tk_getOpenFile -f {{Icons .ico} {"All files" *}}]
    if {$fn eq ""} return
    $w delete 1.1 end
    $w insert end "   $fn\n"
    set i 0
    while 1 {
        if [catch {
            image create photo -file $fn -format "ico -index $i"
        } img] break
        $w insert end [image width $img]x[image height $img]:
        $w image create end -image $img
        $w insert end "   "
        incr i
    }
    if ![string match "Invalid icon index*" $img] {
        $w insert end \n\n$img
    }
 }
#-- Main:
 pack [text .t -height 6 -width 64 -wrap word]
 button .t.load -text Load -command {loadIco .t}
 .t window create end -window .t.load
 loadIco .t

 bind . <Escape> {exec wish $argv0 &; exit}
 bind . <F2> {[image create photo -data .t] write icoview.gif}

See also AniGIF.