5 GIF and Animated GIF Writing
(require mrlib/gif) | package: gui-lib |
procedure
(write-animated-gif bitmaps delay-csec filename [ #:loop? loop? #:one-at-a-time? one-at-a-time? #:last-frame-delay last-frame-delay #:disposal disposal]) → void?
bitmaps :
(and/c (listof (or/c (is-a?/c bitmap%) (-> (is-a?/c bitmap%)))) pair?) delay-csec : (integer-in 0 4294967295) filename : path-string? loop? : any/c = (and delay-csec #t) one-at-a-time? : any/c = #f last-frame-delay : (or/c (integer-in 0 4294967295) #f) = #f disposal : (or/c 'any 'keep 'restore-bg 'restore-prev) = 'any
If one-at-a-time? is #f, then the content of all images is collected and quantized at once, to produce a single colortable; a drawback to this approach is that it uses more memory, and it allows less color variation among animation frames. Even when one-at-a-time? is #f, the result of each thunk in bitmaps is converted to a byte-string one at a time.
If one-at-a-time? is true, then the bitmaps are quantized and written to the file one at a time; that is, for each thunk in bitmaps, its result is written and discarded before another thunk is called. A drawback to this approach is that a separate colortable is written for each frame in the animation, which can make the resulting file large.
If last-frame-delay is not false, a delay of last-frame-delay (in 1/100s of a second) is added to the last frame. This extra delay is useful when loop? is true.
The disposal argument specifies the frame disposal method, which determines how the previous frame is treated when writing a transparent frame. The same disposal method is applied to every frame. See gif-add-control for the meaning of the various disposal options.