The SDL Component Suite is an industry leading collection of components supporting scientific and engineering computing. Please visit the SDL Web site for more information....



ColorToIndex


Unit: SDL_sdlcolors
Class: TColorArray
Declaration: function ColorToIndex (cl: TColor; var distance: double): integer;

The method ColorToIndex searches through the entire color array to find the color most similar to cl. The variable parameter dist returns the distance between the color cl and the most similar color found in the color array. It may assume any value between 0.0 (identical colors) and 1.0 (maximum difference, which is equal to the distance between black and white). The function returns the index of the most similar color.

Hint: Please note that the results of the color comparison may be surprising and may look invalid if the color array contains only a very limited part of the color space (especially if one of the basic colors - red, green, and blue - is missing).



Last Update: 2023-Feb-06