1 /* niff.h:
2  *
3  * header information for xloadimage's native image file format (NIFF),
4  * version 1.
5  *
6  * jimf 10.29.91
7  *
8  * this is in the public domain
9  */
10 
11 #define NIFF_MAGIC 0x4e494646 /* "NIFF" */
12 #define NIFF_VERSION 1        /* this version */
13 
14 /* types of image data
15  */
16 #define NIFF_BITMAP 1
17 #define NIFF_RGB    2
18 #define NIFF_TRUE   3
19 
20 /* colormap entry
21  */
22 struct niff_cmap {
23     char red[2];
24     char green[2];
25     char blue[2];
26 };
27 
28 struct niff_header {
29     char magic[4];     /* NIFF magic number */
30     char version[4];   /* NIFF version */
31     char width[4];     /* image dimensions */
32     char height[4];
33     char depth[4];     /* image depth in bits (true depth, not rounded) */
34     char type;         /* image type */
35     char cmap_size[4]; /* size of colormap; zero NIFF_TRUE */
36     char title_len[4]; /* length of image title */
37     /* title */
38     /* cmap */
39     /* image data */
40 };
41 
42 /* the image title follows the header unless title_len is zero.
43  *
44  * the image colormap follows the title unless the image is NIFF_TRUE
45  * (there must always be at least one cmap entry for NIFF_BITMAP and
46  * NIFF_RGB images).
47  *
48  * the image data follows the cmap data.
49  *
50  * NIFF_BITMAP data is padded to 8-bits, the highest-order bit is the
51  * lowest bitmap pixel.
52  *
53  * NIFF_RGB data is padded to 8-bits per pixel, highest-order byte first.
54  * the number of bytes per pixel is determined by cmap_size (calculate
55  * bits-per-pixel using cmap_size and round up to an 8-bit boundary).
56  *
57  * NIFF_TRUE data is always 3-bytes per pixel - red followed by green
58  * followed by blue, 8 bits each. depth must be 24 and cmap_size must be
59  * zero.
60  */
61