10 #define EPSILON 0.00000001
13 double maxcolor,
int color_mapping_style,
14 double *interval_point,
int interval_mapping_num,
15 int color_system_type) {
18 if (color_mapping_style == 1) {
19 if (fabs(maxcolor - mincolor) >
EPSILON)
20 value = (value - mincolor) / (maxcolor - mincolor);
23 if (color_mapping_style == 2) {
24 mincolor = interval_point[0];
25 maxcolor = interval_point[1];
26 if (fabs(maxcolor - mincolor) >
EPSILON)
27 value = (value - mincolor) / (maxcolor - mincolor);
29 if ((color_mapping_style == 3) || (color_mapping_style == 4)) {
30 if (value < interval_point[0])
32 else if (value > interval_point[interval_mapping_num * 2])
35 for (i = 1; i < interval_mapping_num + 1; i++) {
36 if ((value <= interval_point[i * 2]) &&
37 (value > interval_point[(i - 1) * 2])) {
38 value = (value - interval_point[(i - 1) * 2]) /
39 (interval_point[i * 2] - interval_point[(i - 1) * 2]) *
40 (interval_point[i * 2 + 1] -
41 interval_point[(i - 1) * 2 + 1]) +
42 interval_point[(i - 1) * 2 + 1];
48 if (color_system_type == 1) {
49 if (value < 0.0) value = 0.0;
50 if (value > 1.0) value = 1.0;
55 }
else if ((value > 0.25) && (value <= 0.5)) {
58 b = (0.5 - value) * 4.0;
59 }
else if ((value > 0.5) && (value <= 0.75)) {
60 r = (value - 0.5) * 4.0;
63 }
else if (value > 0.75) {
65 g = (1.0 - value) * 4.0;
69 }
else if (color_system_type == 2) {
70 if (value < 0.0) value = 0.0;
71 if (value > 1.0) value = 1.0;
75 r = (0.2 - value) * 5.0;
76 }
else if ((value > 0.2) && (value <= 0.4)) {
79 g = (value - 0.2) * 5.0;
80 }
else if ((value > 0.4) && (value <= 0.6)) {
83 b = 1.0 - (value - 0.4) * 5.0;
84 }
else if ((value > 0.6) && (value <= 0.8)) {
85 r = (value - 0.6) * 5.0;
88 }
else if (value > 0.0) {
90 g = 1.0 - (value - 0.8) * 5.0;
93 }
else if (color_system_type == 3) {