Decodes a GIF image structure down to chunks, and
also decode the images in the render chunks.
({int xsize,int ysize, // 0: size of image drawing area
void|object colortable, // 2: opt. global colortable
({ int aspx, int aspy, // 3 0: aspect ratio or 0, 0 if not set
int background }), // 2: index of background color
followed by any number these blocks in any order (gce chunks
are decoded and incorporated in the render chunks):
({ GIF.RENDER, // 0: block identifier
int x, int y, // 1: position of render
object image, // 3: render image
void|object alpha, // 4: 0 or render alpha channel
object colortable, // 5: colortable (may be same as global)
int interlace, // 6: interlace flag
int trans_index, // 7: 0 or transparent color index
int delay, // 8: 0 or delay in centiseconds
int user_input, // 9: user input flag
int disposal}) // 10: disposal method number (0..7)
({ GIF.EXTENSION, // 0: block identifier
int extension, // 1: extension number
string data }) // 2: extension data
and possibly ended with one of these:
({ GIF.ERROR_PREMATURE_EOD }) // premature end-of-data
({ GIF.ERROR_TOO_MUCH_DATA, // data following end marker
string data }) // (rest of file)
({ GIF.ERROR_UNKNOWN_DATA, // unknown data
string data }) // (rest of file)
The decode method uses this data in a way similar
to this program:
import Image;
object my_decode_gif(string data)
{
array a=GIF._decode(data);
object img=image(a[0],a[1]);
foreach (a[4..],array b)
if (b[0]==GIF.RENDER)
if (b[4]) img->paste_alpha(b[3],b[4],b[1],b[2]);
else img->paste(b[3],b[1],b[2]);
return img;
}