I'm making a separate, proper request, because the other one about GIF was a bit all over the place.

So basically both /drawpic -o N and $pic(,N).delay are too slow in execution to be able to properly animate most animated GIF which have approximately constant delay of 30-40 ms between frame.
You can check their timing in pretty much any script made to animate a GIF, I'll post the script from Khaled:

Code
test {
  %fname = $getdir $+ mircnow5.gif
  echo fname: %fname
  if ($exists(%fname)) {
    showgif
    return
  }
  var %url = https://www.mirc.com/images/mircnow5.gif
  echo urlget: $urlget(%url,gf,%fname,showgif)
}
showgif {
  if (!$exists(%fname)) return

  %icons = $pic(%fname).icons
  echo icons: %icons

  if (%icons > 0) {
    %frames = $pic(%fname).frames
    echo frames: %frames

    if (%frames > 0) {
      %w = $calc($pic(%fname).width + 20)
      %h = $calc($pic(%fname).height + 20)

      window -pf @test 10 10 %w %h
      drawrect -fr @test $rgb(255,255,255) 1 0 0 %w %h

      %i = 0
      .timergif -m 1 0 showframe
    }
  }
}
showframe {
  if (!$window(@test)) return

  drawrect -nfr @test $rgb(255,255,255) 1 0 0 %w %h
  drawpic -to @test $rgb(0,255,0) 10 10 %i %fname

  %delay = $pic(%fname,%i).delay
  echo i: %i delay: %delay
  .timergif -m 1 %delay showframe

  inc %i
  if (%i >= %frames) %i = 0
}
Again, the mircnow5.gif from mIRC displays fine but that's because delays are huge, or they isn't enough fast frames to notice, or maybe there's another reason but when you're working with more regular gif like the one I tested here https://tenor.com/view/johnny-laugh-four-gif-7446278225827837893, the animation is extremely slow.
I can't stress enough how slow it renders such gif even on modern hardware.
In my test, both /drawpic -o and $pic().delay at frame 1 takes 30ms to execute, and the more the frame number increase, the slow them both become, with /drawpic taking up to 60-70ms to render on the last frame (frame 71th) and $pic().delay taking up to 60ms on that last frame.
Caching the frame and the $pic().delay values and drawing them with drawcopy allows one to animate any GIF properly. But the initialization and caching processus, in my example, means that I'm waiting 3-4 seconds from the moment I want to animate the gif and when it actually starts to display, 3-4 seconds where mIRC is unresponsive in a loop /drawpicing and caching $pic().delay.

I suppose this slowdown is due to mIRC or the GIF lib having to open/close the file twice (/drawpic and $pic()) per frame. Whereas a typical external application displaying an animated GIF wouldn't have to interface anything for a scripting language, so the file is kept open (and more optimization may occur).

Would it be possible to improve the interfacing with the scripting language by keeping the file open ?

/gifopen <handle> <filename>
/drawpic -Ho .... <handle>
$gif(<handle>,N).delay
$gif(<handle>).frames
$gif(<handle>).width
$gif(<handle>).height

Last edited by Khaled; 29/04/26 05:53 AM.

#mircscripting @ irc.swiftirc.net == the best mIRC help channel