-static int FindNearestColor( unsigned int color )
-{
- int i;
- int closest_so_far = 0;
- float closest_distance_so_far = 100000000;
- float d;
- float r[2], g[2], b[2];
-
- // incoming color is assumed to be in 0xRRGGBB format
- r[0] = ( color & 31 ) << 3;
- g[0] = ( ( color >> 5 ) & 63 ) << 2;
- b[0] = ( ( color >> 11 ) & 31 ) << 3;
-
- for ( i = 0; i < 256; i++ )
- {
- r[1] = ( d_8to24table[i] >> 0 ) & 0xFF;
- g[1] = ( d_8to24table[i] >> 8 ) & 0xFF;
- b[1] = ( d_8to24table[i] >> 16 ) & 0xFF;
-
- d = ( r[1] - r[0] ) * ( r[1] - r[0] ) +
- ( g[1] - g[0] ) * ( g[1] - g[0] ) +
- ( b[1] - b[0] ) * ( b[1] - b[0] );
-
- if ( d < closest_distance_so_far )
- {
- closest_distance_so_far = d;
- closest_so_far = i;
- }
- }
-
- return closest_so_far;
-}
-*/
+ static int FindNearestColor( unsigned int color )
+ {
+ int i;
+ int closest_so_far = 0;
+ float closest_distance_so_far = 100000000;
+ float d;
+ float r[2], g[2], b[2];
+
+ // incoming color is assumed to be in 0xRRGGBB format
+ r[0] = ( color & 31 ) << 3;
+ g[0] = ( ( color >> 5 ) & 63 ) << 2;
+ b[0] = ( ( color >> 11 ) & 31 ) << 3;
+
+ for ( i = 0; i < 256; i++ )
+ {
+ r[1] = ( d_8to24table[i] >> 0 ) & 0xFF;
+ g[1] = ( d_8to24table[i] >> 8 ) & 0xFF;
+ b[1] = ( d_8to24table[i] >> 16 ) & 0xFF;
+
+ d = ( r[1] - r[0] ) * ( r[1] - r[0] ) +
+ ( g[1] - g[0] ) * ( g[1] - g[0] ) +
+ ( b[1] - b[0] ) * ( b[1] - b[0] );
+
+ if ( d < closest_distance_so_far )
+ {
+ closest_distance_so_far = d;
+ closest_so_far = i;
+ }
+ }
+
+ return closest_so_far;
+ }
+ */