QDV format Copyright 1987 Steve Blackstock 1-29-88 QDV is a file format designed to store color pixel-mapped images very simply. No compression is used, so this format has limited usefulness. However, it is very simple, and code that reads and writes it will be easy to write and fast to execute. This document describes QDV format, version 1.0 (Jan 29, 1987). I reserve the right to modify the format if I also modify the version number and publicize the change well. The format is public domain, and anyone may use it. However, IT MAY NOT BE MODIFIED without my express permission. Here it is: The first four bytes are the image dimension specification. The first two bytes are the width of the image, in pixels. They constitute an MC68000 word, which means the MOST SIGNIFICANT BYTE IS FIRST. The next two bytes are the height of the image, in pixels. In the dimension specification, width and height are limited to the range [0,16383] (inclusive). That is, the most significant two bits of each dimension must be clear. Immediately following the dimension specification is the color map. The first byte is one less than the number of colors in the map. That is, a value of 1 means 2 colors, and a value of 255 (maximum) means 256 colors. Then, each color is given as 3 bytes each: the first for RED, the second for GREEN, and the third for BLUE. The minimum value for each component is 0, and the maximum is 255. So, 0,0,0 means black and 255,255,255 means white. 255,0,0 is pure red, 0,255,0 is pure green, and so on. There are N triplets of bytes here, assuming the first byte in the map was N-1. There are a couple of rules you should try to follow in ordering the colors in the map. While following these rukes is not mandatory, it is highly recommended. First, The color map should include white (255,255,255) in the first postion (color 0), and black (0,0,0) in the last position (color N-1). Second, the remaining colors should be sorted according to their frequency of occurrence in the image. So, the color map would look like this: white most frequently used color next most frequent . . . least frequent black Immediately following the color map is the raster data, one byte per pixel. The order of the pixels is: pixel 1 of row 1, pixel 2 of row 1, pixel 3 of row 1, ..., pixel 1 of row 2, pixel 2 of row 2, etc. Each pixel value represents an index into the above color table, which specifies what color the pixel should have. That's it! Here's a diagram: ----------------- | | | width | (2 bytes, HSB first, highest 2 bits clear) ------------------ | | | height | (2 bytes, HSB first, highest 2 bits clear) ------------------ | N-1 | (1 byte N= number of colors) ------------------ | red | | green | (color #0, 3 bytes) | blue | ------------------ | red | | green | (color #1, 3 bytes) | blue | ------------------ . . . ------------------ | red | | green | (color #(N-1), 3 bytes) | blue | ------------------ | pixel 1 | ------------------ | pixel 2 | ------------------ . . . (all pixels, across first, then down) END Any comments or questions regarding QDV format should be addressed to: Steve Blackstock 40 Bartlett Ave Lexington, MA 02173 CompuServe: [73270,1150]