Location: PHPKode > scripts > dGifAnimator > dgifanimator/GIF_Format.htm
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=(0047)http://www.onicos.com/staff/iz/formats/gif.html -->
<HTML><HEAD><TITLE>GIF format</TITLE>
<META http-equiv=Content-Type content="text/html; charset=windows-1252">
<META content="MSHTML 6.00.2900.2802" name=GENERATOR></HEAD>
<BODY>
<H1>GIF format</H1>Byte Order: Little-endian<BR><A name=header></A>
<H2>GIF Header</H2><PRE>Offset   Length   Contents
  0      3 bytes  "GIF"
  3      3 bytes  "87a" or "89a"
  6      2 bytes  &lt;Logical Screen Width&gt;
  8      2 bytes  &lt;Logical Screen Height&gt;
 10      1 byte   bit 0:    Global Color Table Flag (GCTF)
                  bit 1..3: Color Resolution
                  bit 4:    Sort Flag to Global Color Table
                  bit 5..7: Size of Global Color Table: 2^(1+n)
 11      1 byte   &lt;Background Color Index&gt;
 12      1 byte   &lt;Pixel Aspect Ratio&gt;
 13      ? bytes  &lt;Global Color Table(0..255 x 3 bytes) if GCTF is one&gt;
         ? bytes  &lt;<B>Blocks</B>&gt;
         1 bytes  &lt;Trailer&gt; (0x3b)
</PRE><A name=ib></A>
<H2>Image Block</H2><PRE>Offset   Length   Contents
  0      1 byte   Image Separator (0x2c)
  1      2 bytes  Image Left Position
  3      2 bytes  Image Top Position
  5      2 bytes  Image Width
  7      2 bytes  Image Height
  8      1 byte   bit 0:    Local Color Table Flag (LCTF)
                  bit 1:    Interlace Flag
                  bit 2:    Sort Flag
                  bit 2..3: Reserved
                  bit 4..7: Size of Local Color Table: 2^(1+n)
         ? bytes  Local Color Table(0..255 x 3 bytes) if LCTF is one
         1 byte   LZW Minimum Code Size
[ // Blocks
         1 byte   Block Size (s)
        (s)bytes  Image Data
]*
         1 byte   Block Terminator(0x00)
</PRE><A name=gceb></A>
<H2>Graphic Control Extension Block</H2><PRE>Offset   Length   Contents
  0      1 byte   Extension Introducer (0x21)
  1      1 byte   Graphic Control Label (0xf9)
  2      1 byte   Block Size (0x04)
  3      1 byte   bit 0..2: Reserved
                  bit 3..5: Disposal Method
                  bit 6:    User Input Flag
                  bit 7:    Transparent Color Flag
  4      2 bytes  Delay Time (1/100ths of a second)
  6      1 byte   Transparent Color Index
  7      1 byte   Block Terminator(0x00)
</PRE><A name=ceb></A>
<H2>Comment Extension Block</H2><PRE>Offset   Length   Contents
  0      1 byte   Extension Introducer (0x21)
  1      1 byte   Comment Label (0xfe)
[
         1 byte   Block Size (s)
        (s)bytes  Comment Data
]*
         1 byte   Block Terminator(0x00)
</PRE><A name=pteb></A>
<H2>Plain Text Extension Block</H2><PRE>Offset   Length   Contents
  0      1 byte   Extension Introducer (0x21)
  1      1 byte   Plain Text Label (0x01)
  2      1 byte   Block Size (0x0c)
  3      2 bytes  Text Grid Left Position
  5      2 bytes  Text Grid Top Position
  7      2 bytes  Text Grid Width
  9      2 bytes  Text Grid Height
 10      1 byte   Character Cell Width(
 11      1 byte   Character Cell Height
 12      1 byte   Text Foreground Color Index(
 13      1 byte   Text Background Color Index(
[
         1 byte   Block Size (s)
        (s)bytes  Plain Text Data
]*
         1 byte   Block Terminator(0x00)
</PRE><A name=aeb></A>
<H2>Application Extension Block</H2><PRE>Offset   Length   Contents
  0      1 byte   Extension Introducer (0x21)
  1      1 byte   Application Label (0xff)
  2      1 byte   Block Size (0x0b)
  3      8 bytes  Application Identifire
[
         1 byte   Block Size (s)
        (s)bytes  Application Data
]*
         1 byte   Block Terminator(0x00)
</PRE>
<HR>
<PRE>GIF87a:

<A href="http://www.onicos.com/staff/iz/formats/gif.html#header">GIF Header</A>
<A href="http://www.onicos.com/staff/iz/formats/gif.html#ib">Image Block</A>
Trailer
</PRE>
<HR>
<PRE>GIF89a:

<A href="http://www.onicos.com/staff/iz/formats/gif.html#header">GIF Header</A>
<A href="http://www.onicos.com/staff/iz/formats/gif.html#gceb">Graphic Control Extension</A>
<A href="http://www.onicos.com/staff/iz/formats/gif.html#ib">Image Block</A>
Trailer
</PRE>
<HR>
<PRE>GIF Animation

<A href="http://www.onicos.com/staff/iz/formats/gif.html#header">GIF Header</A>
<A href="http://www.onicos.com/staff/iz/formats/gif.html#aeb">Application Extension</A>
[
  <A href="http://www.onicos.com/staff/iz/formats/gif.html#gceb">Graphic Control Extension</A>
  <A href="http://www.onicos.com/staff/iz/formats/gif.html#ib">Image Block</A>
]*
Trailer
</PRE></BODY></HTML>
Return current item: dGifAnimator