You are on page 1of 8

GIF format

Byte Order: Little-endian

GIF Header
Offset
0
3
6
8
10

11
12
13

Length
3 bytes
3 bytes
2 bytes
2 bytes
1 byte

1
1
?
?
1

byte
byte
bytes
bytes
bytes

Contents
"GIF"
"87a" or "89a"
<Logical Screen Width>
<Logical Screen Height>
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)
<Background Color Index>
<Pixel Aspect Ratio>
<Global Color Table(0..255 x 3 bytes) if GCTF is one>
<Blocks>
<Trailer> (0x3b)

Image Block
Offset
0
1
3
5
7
8

Length
1 byte
2 bytes
2 bytes
2 bytes
2 bytes
1 byte

? bytes
1 byte
[ // Blocks
1 byte
(s)bytes
]*
1 byte

Contents
Image Separator (0x2c)
Image Left Position
Image Top Position
Image Width
Image Height
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)
Local Color Table(0..255 x 3 bytes) if LCTF is one
LZW Minimum Code Size
Block Size (s)
Image Data
Block Terminator(0x00)

Graphic Control Extension Block


Offset
0
1
2
3

Length
1 byte
1 byte
1 byte
1 byte

Contents
Extension Introducer (0x21)
Graphic Control Label (0xf9)
Block Size (0x04)
bit 0..2: Reserved

4
6
7

2 bytes
1 byte
1 byte

bit 3..5: Disposal Method


bit 6:
User Input Flag
bit 7:
Transparent Color Flag
Delay Time (1/100ths of a second)
Transparent Color Index
Block Terminator(0x00)

Comment Extension Block


Offset
0
1
[

Length
1 byte
1 byte
1 byte
(s)bytes

]*

1 byte

Contents
Extension Introducer (0x21)
Comment Label (0xfe)
Block Size (s)
Comment Data
Block Terminator(0x00)

Plain Text Extension Block


Offset
0
1
2
3
5
7
9
10
11
12
13
[
]*

Length
1 byte
1 byte
1 byte
2 bytes
2 bytes
2 bytes
2 bytes
1 byte
1 byte
1 byte
1 byte
1 byte
(s)bytes
1 byte

Contents
Extension Introducer (0x21)
Plain Text Label (0x01)
Block Size (0x0c)
Text Grid Left Position
Text Grid Top Position
Text Grid Width
Text Grid Height
Character Cell Width(
Character Cell Height
Text Foreground Color Index(
Text Background Color Index(
Block Size (s)
Plain Text Data
Block Terminator(0x00)

Application Extension Block


Offset
0
1
2
3
[
]*

Length
1 byte
1 byte
1 byte
8 bytes
1 byte
(s)bytes
1 byte

GIF87a:

Contents
Extension Introducer (0x21)
Application Label (0xff)
Block Size (0x0b)
Application Identifire
Block Size (s)
Application Data
Block Terminator(0x00)

GIF Header
Image Block
Trailer
GIF89a:
GIF Header
Graphic Control Extension
Image Block
Trailer
GIF Animation
GIF Header
Application Extension
[
Graphic Control Extension
Image Block
]*
Trailer

JPEG Image Header


offset

size

description

JPEG SOI marker (FFD8 hex)

image width in pixels

image height in pixels

number of components (1 = grayscale, 3 = RGB)

horizontal/vertical sampling factors for component 1

sampling factors for component 2 (if RGB)

sampling factors for component 3 (if RGB)

AVI Header Format


AVI files contain a 56-byte header, starting at offset 32 within the file.
offset

size

description

time delay between frames in microseconds

data rate of AVI data

padding multiple size, typically 2048

12

parameter flags

16

number of video frames

20

number of preview frames

24

number of data streams (1 or 2)

28

suggested playback buffer size in bytes

32

width of video image in pixels

36

height of video image in pixels

40

time scale, typically 30

44

data rate (frame rate = data rate / time scale)

48

starting time, typically 0

52

size of AVI data chunk in time scale units

BMP (OS/2) Header Format


OS/2 BMP files begin with a 26-byte header:
offset

size

description

signature, must be 4D42 hex

size of BMP file in bytes (unreliable)

reserved, must be zero

reserved, must be zero

10

offset to start of image data in bytes

14

size of BITMAPCOREHEADER structure, must be 12

18

image width in pixels

20

image height in pixels

22

number of planes in the image, must be 1

24

number of bits per pixel (1, 4, 8, or 24)

BMP (Windows) Header Format


Windows BMP files begin with a 54-byte header:
offset

size

description

signature, must be 4D42 hex

size of BMP file in bytes (unreliable)

reserved, must be zero

reserved, must be zero

10

offset to start of image data in bytes

14

size of BITMAPINFOHEADER structure, must be 40

18

image width in pixels

22

image height in pixels

26

number of planes in the image, must be 1

28

number of bits per pixel (1, 4, 8, or 24)

30

compression type (0=none, 1=RLE-8, 2=RLE-4)

34

size of image data in bytes (including padding)

38

horizontal resolution in pixels per meter (unreliable)

42

vertical resolution in pixels per meter (unreliable)

46

number of colors in image, or zero

50

number of important colors, or zero

You might also like