intro
anim = N images (max 15s to few minutes) 256 color palette transparency color, no alpha LZW compression > run length can be uncompressed ~hack of LZW pretty simple and straightforward spec is very readable & small
GIF Data Stream: sequential, byte stream, LSB
1 2 3 4 5 6 7 8 9 10 11 12 13 |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
|
sub-block and data blocks vary size 256 bytes max (including block size field)
image data and ext data has sub-blocks
1st byte = sub-block size (N) [0..255] block size field (for skipping) #bytes remaining in block !count block size field !count block terminator if present N bytes = sub-block data
block terminator : sub-block w size=0
sub-blocks parse logic can be shared but 2x fread
6 bytes magic version GIF87a: base GIF89a: anim, 1-bit transparency, text overlay modern browsers, image editors, and social media platforms ignore the text extension most web browsers automatically displaying the frames with a delay time of 0.1 seconds
7 bytes w x h GCT size transparent color
logical screen images = frames or subimages
array of colors (R,G,B) N = #colors, max 256 size = 3 x 2^(N+1)
might be sorted in order of importance, most frequent color first
color palette 1x GCT per file 1x LCT per image/graphics GCT if no LCT only use one at a time
10 bytes start with 0x2C pos of image (and size) in screen interlaced? size of LCT
same as GCT, can be sorted
1st byte = LZW min code size N sub-blocks for each pixel, left to right and from top to bottom index to color table encoded in LZW
conclusion