text: Compute an inverse colormap. More...
  #include "csextern.h"
  #include "rgbpixel.h"
  Go to the source code of this file.
  Detailed Description
  Compute an inverse colormap.
  Definition in file inv_cmap.h.
  Function Documentation
  Compute an inverse colormap efficiently.
  Inputs: colors: Number of colors in the forward colormap. colormap: The forward colormap. rbits, gbits, bbits: Number of quantization bits. The inverse colormap will have N=(2^rbits)*(2^gbits)*(2^bbits) entries. dist_buf: An array of N long integers to be used as scratch space. If 0, the dist_buff will be allocated and freed before exiting the routine. Outputs: rgbmap: The output inverse colormap. The entry rgbmap[(r<<(gbits+bbits)) + (g<<bbits) + b] is the colormap entry that is closest to the (quantized) color (r,g,b). If 0, it will be allocated with "new uint8* []" Assumptions: Quantization is performed by right shift (low order bits are truncated). Thus, the distance to a quantized color is actually measured to the color at the center of the cell (i.e., to r+.5, g+.5, b+.5, if (r,g,b) is a quantized color). Algorithm: Uses a "distance buffer" algorithm: The distance from each representative in the forward color map to each point in the rgb space is computed. If it is less than the distance currently stored in dist_buf, then the corresponding entry in rgbmap is replaced with the current representative (and the dist_buf entry is replaced with the new distance).
  The distance computation uses an efficient incremental formulation.
  Distances are computed "outward" from each color. If the colors are evenly distributed in color space, the expected number of cells visited for color I is N^3/I. Thus, the complexity of the algorithm is O(log(K) N^3), where K = colors, and N = 2^bits.
  BUGBUG: For some unknown reason the routine generates colormaps shifted towards red if green is bigger than red (and vice versa, shifted to green if red is bigger). Thus it is adviced to use same resolution for R and G. If someone can find out why it happens, he is free to do it -- A.Z.
  Generated for Crystal Space 1.4.1 by doxygen 1.7.1