Import std.image.gif
std.image.gif
GIF, read and written by the runtime itself: Gif.Decode reads a GIF's first frame, and DecodeAnimation every frame, each as it's shown once the frames before it are, drawn as browsers draw them, on a canvas that starts transparent. Encode and EncodeAnimation make each frame the whole image, with a palette of its own, of its colors when there are 256 or fewer, counting one for those whose alpha is below 128, which are transparent, or else the 256 median cut picks, 255 and the transparent one when one is, with Floyd-Steinberg dithering.
std/image/gif.fb
Types
Gif
struct
Public Struct Gif
What reads and writes GIF images and animations, in its Static Methods.
-
@PanicsAtCaller Public Static Method Decode(data: UInt8[], limit: Int = MOST_PIXELS): Image Throws IOErrorstatic method #The first frame of the GIF in
data. Throws an IOError of INVALID_DATA when thedataisn't a GIF or is broken, and OTHER when the frame has more pixels thanlimit. Panics when thelimitis negative. -
@PanicsAtCaller Public Static Method DecodeAnimation(data: UInt8[], limit: Int = MOST_PIXELS): Animation Throws IOErrorstatic method #The frames of the GIF in
data, each as it's shown once the frames before it are, its delay in hundredths of a second as milliseconds, and how many times they play, by the NETSCAPE2.0 extension, which counts the times after the first, or once without it. Throws an IOError as Decode does, of OTHER when the frames, all their pixels counted, have more thanlimit. Panics when thelimitis negative. -
The GIF of the
image, one frame. Panics when it has no pixels or a side longer than 65535. -
The GIF of the
animation's frames, each delay in hundredths of a second, rounded, and each frame drawn on a transparent canvas. Panics when theanimationhas no frames, no pixels, a side longer than 65535, a frame whose image isn't its size, or one longer than 655350 milliseconds, or plays more than 65536 times, which GIF can't count.
Report an issue with this page or with FutureBlitz on GitHub.