Graphics Interchange Format
Format type | Image |
---|---|
Hardware | Unknown |
Colour depth | 8-bit |
Minimum size (pixels) | 0×0 |
Maximum size (pixels) | 65536×65536 |
Palette | Internal |
Plane count | Unknown |
Transparent pixels? | Yes |
Hitmap pixels? | No |
Games |
The Graphics Interchange Format (GIF) stores images with palettes of up to 256 colors and enjoyed widespread use. It supports transparency, the possibility of multiple frames in a file, animation, and LZW Compression.
Header
The header specifies some information that applies to the image as a whole, including a maximum width and height that all frames within the file must fit inside.
Data type | Description |
---|---|
char[3] | "GIF" |
char[3] | Version mark (e.g. "87a") |
UINT16LE | How many pixels wide the entire viewport is |
UINT16LE | How many pixels tall the entire viewport is |
BYTE |
|
UINT8 | Palette index of transparent color; ignored if the global color table bit is unset. |
UINT8 | Pixel aspect ratio (0 = default) |
Color tables
If the relevant bit is set in the header, then a global color table (palette) will appear immediately after the GIF header, containing the number of colors also indicated in the header.
Every color consists of three bytes, which may use their full 0-255 range of values:
Data type | Description |
---|---|
UINT8 | Red component |
UINT8 | Green component |
UINT8 | Blue component |
Local color tables (used for a single frame in a multi-frame image) are also possible.
Image descriptor
Every image in a GIF file (even single frame GIFs) must have its own image descriptor.
Data type | Description |
---|---|
BYTE | Image separator, always 0x2C |
UINT16LE | Pixel position of frame's left edge relative to total viewport (0 = leftmost column) |
UINT16LE | Pixel position of frame's top edge relative to total viewport (0 = topmost row) |
UINT16LE | Width of frame in pixels |
UINT16LE | Height of frame in pixels |
BYTE |
|
If a local color table is present, it appears immediately after the image descriptor. Next comes the compressed image data for the frame.
End of file
A GIF file must end with a byte whose value is 0x3B.