12 |
|
|
13 |
|
#include <stdio.h> |
14 |
|
#include <string.h> |
15 |
+ |
#include <math.h> |
16 |
|
#include "color.h" |
17 |
|
|
18 |
|
#define CEPS 1e-4 /* color epsilon */ |
406 |
|
) |
407 |
|
{ |
408 |
|
return(scolor2melanopic(scol, NCSAMP, WLPART)); |
409 |
+ |
} |
410 |
+ |
|
411 |
+ |
|
412 |
+ |
void |
413 |
+ |
convertscolorcol( /* any uniform spectrum to working */ |
414 |
+ |
SCOLOR rcol, |
415 |
+ |
const COLORV src[], |
416 |
+ |
int snc, |
417 |
+ |
double swl0, |
418 |
+ |
double swl1 |
419 |
+ |
) |
420 |
+ |
{ |
421 |
+ |
if (NCSAMP > 3) { /* spectrum -> spectrum */ |
422 |
+ |
convertscolor(rcol, NCSAMP, WLPART[0], WLPART[3], |
423 |
+ |
src, snc, swl0, swl1); |
424 |
+ |
} else if ((snc <= MAXCSAMP) & (swl0 > swl1)) { |
425 |
+ |
float wlpt[4]; /* no intermediate conversion needed */ |
426 |
+ |
wlpt[0] = swl0; wlpt[3] = swl1; |
427 |
+ |
wlpt[1] = WLPART[1]; wlpt[2] = WLPART[2]; |
428 |
+ |
scolor2rgb(rcol, (COLORV *)src, snc, wlpt); |
429 |
+ |
} else { |
430 |
+ |
SCOLOR dcol; /* else convert spectrum first */ |
431 |
+ |
int dnc = snc*(WLPART[0] - WLPART[3])/fabs(swl0 - swl1) + .99; |
432 |
+ |
if (dnc > MAXCSAMP) dnc = MAXCSAMP; |
433 |
+ |
convertscolor(dcol, dnc, WLPART[0], WLPART[3], src, snc, swl0, swl1); |
434 |
+ |
scolor2rgb(rcol, dcol, dnc, WLPART); |
435 |
+ |
} |
436 |
|
} |
437 |
|
|
438 |
|
|