Changeset 38146
- Timestamp:
- Apr 17, 2015, 3:06:54 PM (11 years ago)
- Location:
- branches/eam_branches/ipp-20150405/Ohana/src/kapa2
- Files:
-
- 2 added
- 1 edited
-
doc/rainbow.cm (added)
-
doc/vista.cm (added)
-
src/SetColormap.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20150405/Ohana/src/kapa2/src/SetColormap.c
r38099 r38146 205 205 goto store_colors; 206 206 } 207 208 /* anuenue */ 209 if (!strncmp (name, "file:", 5)) { 210 FILE *f = fopen (&name[5], "r"); 211 if (!f) { 212 fprintf (stderr, "failed to open colormap file %s\n", &name[5]); 213 return FALSE; 214 } 215 char line[1024]; 216 217 int lastIndex = 0; 218 float lastRed = 0.0; 219 float lastBlue = 0.0; 220 float lastGreen = 0.0; 221 222 float fracIndex, fracRed, fracBlue, fracGreen; 223 224 while (scan_line_maxlen (f, line, 1024) != EOF) { 225 // file contains f R G B : f = 0.0 - 1.0, R,G,B = 0.0 - 1.0 226 int Nscan = sscanf (line, "%f %f %f %f", &fracIndex, &fracRed, &fracBlue, &fracGreen); 227 if (Nscan != 4) continue; 228 229 int nextIndex = fracIndex * MaxValue; 230 if (nextIndex <= lastIndex) { 231 lastRed = fracRed; 232 lastBlue = fracBlue; 233 lastGreen = fracGreen; 234 continue; 235 } 236 float dRdI = (fracRed - lastRed) / (float) (nextIndex - lastIndex); 237 float dBdI = (fracBlue - lastBlue) / (float) (nextIndex - lastIndex); 238 float dGdI = (fracGreen - lastGreen) / (float) (nextIndex - lastIndex); 239 for (i = lastIndex; i < nextIndex; i++) { 240 float redValue = 0xffff * (dRdI * (i - lastIndex) + lastRed); 241 float blueValue = 0xffff * (dBdI * (i - lastIndex) + lastBlue); 242 float greenValue = 0xffff * (dGdI * (i - lastIndex) + lastGreen); 243 SETVALUE (graphic[0].cmap[i].red, redValue, 0, 0xffff); 244 SETVALUE (graphic[0].cmap[i].blue, blueValue, 0, 0xffff); 245 SETVALUE (graphic[0].cmap[i].green, greenValue, 0, 0xffff); 246 } 247 lastRed = fracRed; 248 lastBlue = fracBlue; 249 lastGreen = fracGreen; 250 lastIndex = nextIndex; 251 } 252 fclose (f); 253 254 if ((int) (MaxValue*fracIndex) < MaxValue) { 255 float dRdI = (1.0 - lastRed) / (float) (MaxValue - lastIndex); 256 float dBdI = (1.0 - lastBlue) / (float) (MaxValue - lastIndex); 257 float dGdI = (1.0 - lastGreen) / (float) (MaxValue - lastIndex); 258 for (i = lastIndex; i < MaxValue; i++) { 259 float redValue = 0xffff * (dRdI * (i - lastIndex) + lastRed); 260 float blueValue = 0xffff * (dBdI * (i - lastIndex) + lastBlue); 261 float greenValue = 0xffff * (dGdI * (i - lastIndex) + lastGreen); 262 SETVALUE (graphic[0].cmap[i].red, redValue, 0, 0xffff); 263 SETVALUE (graphic[0].cmap[i].blue, blueValue, 0, 0xffff); 264 SETVALUE (graphic[0].cmap[i].green, greenValue, 0, 0xffff); 265 } 266 } 267 goto store_colors; 268 } 269 207 270 return (FALSE); 208 271
Note:
See TracChangeset
for help on using the changeset viewer.
