Updated 2014-02-06 19:54:51 by dkf

George Peter Staplin Sep 24, 2007 - Animngext is a portable Tcl extension that uses animng and megaimage. It's available from megapkg

Here's an example demo:
set dir [file dirname [info script]]
source [file join $dir demoarch.tcl]

set fd [open [lindex $argv 0] r]
fconfigure $fd -translation binary

set obj [animng [read $fd]]
close $fd

set frames [$obj gettotalframes]
set images [list]
for {set i 0} {$i < $frames} {incr i} {
  set image [list]
  lappend image [$obj getframe x y delay]
  lappend image $delay
  lappend images $image
}

proc next-image {images mobj step} {
  lassign [lindex $images $step] data delay
  $mobj setdata $data
  .f objsetimage $mobj
  puts "$step $delay"
  incr step
  if {$step >= [llength $images]} {
    set step 0
  } 
  after $delay [list next-image $images $mobj $step]
}

megaimage.frame .f
.f size 300 300
pack .f -expand 1 -fill both
set mobj [megaimage-blank 1 1]
next-image $images $mobj 0

Note: to destroy an animng instance use: rename $inst {} Currently there is no support for writing animng files from Tcl. It's hoped that in the future this will be done...