This page describes the DIF Image format, and is not finished yet.
The DIF, or Dictionary Image Format, image format is a text-based image format that can encode bitmap images. It supports compression, the definition of custom color palates, termed "dictionaries", and the potential inclusion of metadata.
The basic layout of a raw DIF file is below:
!DIF !!HEAD VERSION=1.0 WIDTH=10 HEIGHT=10 DEFSIZE=1 USEDICT= !!DEF b=0,0,0 w=255,255,255 !!IMG bbbbbbbbbb wwwwwwwwww bbbbbbbbbb wwwwwwwwww bbbbbbbbbb wwwwwwwwww bbbbbbbbbb wwwwwwwwww bbbbbbbbbb wwwwwwwwww !!ENDEvery DIF file begins with the line !DIF. After this the file is broken up into three sections, HEAD, DEF, and IMG.
The HEAD section defines several important variables that can be defined in any order:
If you would like, you can also defined other variables in this section for things like metadata using the format KEY=value. However, software may ignore these other variables.
If no color dictionary is specified with USEDICT, then the color definitions must be specified the DEF section. Each line contains one color definition in the format definition=r,g,b, where definition is any string of ASCII characters that is the length of the image DEFSIZE, and r, g, and b are numbers between 0 and 255 that represent an RGB color (for example 0,0,0 is black and 255,255,255 is white).
This section is where the color of each pixel is defined. Each line defines one row of the image, and every DEFSIZE characters is a pixel. In the example above, that means that each b and w is a pixel, a black and white one respectively. However, this is not true for the image below:
!DIF !!HEAD VERSION=1.0 WIDTH=10 HEIGHT=10 DEFSIZE=2 !!DEF bb=0,0,0 ww=255,255,255 !!IMG bbbbbbbbbbbbbbbbbbbb wwwwwwwwwwwwwwwwwwww bbbbbbbbbbbbbbbbbbbb wwwwwwwwwwwwwwwwwwww bbbbbbbbbbbbbbbbbbbb wwwwwwwwwwwwwwwwwwww bbbbbbbbbbbbbbbbbbbbh wwwwwwwwwwwwwwwwwwww bbbbbbbbbbbbbbbbbbbb wwwwwwwwwwwwwwwwwwww !!ENDIn this image, each bb and ww is a pixel, because the DEFSIZE is 2, not 1.
While DIF images can and do contain custom color dictionaries within themselves, most times the use of an external color dictionary is opted for, because it is easier, and, when a DIF image uses many different colors, can reduce file size. In order to ensure that a wide variety of images can be displayed, the inclusion of certain color dictionaries is mandated (see the list below). There is also the special case of the Base 52 RGB dictionary.