Manual Reference Pages - INV_CMAP (3)
inv_cmap - efficiently compute an inverse colormap
int colors, bits;
void inv_cmap( colors, colormap, bits, dist_buf, rgbmap )
unsigned char *colormap, *rgbmap;
unsigned long *dist_buf;
Inv_cmap computes an inverse colormap to translate an RGB color to the nearest
color in the given colormap. The arguments are
Predicted performance is O(2^(3*bits)*log(colors)). The
measured performance is sublinear (but not as good as log) in
the number of input colors and also in the size of the output inverse
colormap. (I.e., it goes up more slowly than 2^(3*bits).)
The number of colors in the input colormap. Must be 256.
The input colormap. The ith color is (Colormap[i],
Controls the size and precision of the inverse colormap. The
resulting colormap will be a cube 2^bits on a side, and will
therefore contain 2^(3*bits) entries. RGB colors must be
quantized to bits bits before using the inverse colormap.
Temporary storage used by inv_cmap. It should contain at least
The inverse colormap. Should be allocated with at least
2^(3*bits) elements. After calling inv_cmap, an RGB color
(r,g,b) can be mapped to its closest representative in colormap
#define quantize(p) ((p)>>(8-bits))
rgbmap[ (((quantize(r) << bits) | quantize(g)) << bits) | quantize(b) ]
Spencer W. Thomas
|1 ||INV_CMAP (3) ||Month DD, YYYY |
Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.