10 |
|
|
11 |
|
#include <stdio.h> |
12 |
|
#include <ctype.h> |
13 |
+ |
#include "color.h" |
14 |
|
|
15 |
|
extern char *eindex(), *expsave(), *malloc(); |
16 |
< |
extern FILE *fropen(); |
16 |
> |
extern FILE *frlibopen(); |
17 |
|
|
18 |
|
typedef struct lamp { |
19 |
|
char *pattern; /* search pattern */ |
49 |
|
char buf[128], str[128]; |
50 |
|
register char *cp1, *cp2; |
51 |
|
|
52 |
< |
if ((fp = fropen(file)) == NULL) |
52 |
> |
if ((fp = frlibopen(file)) == NULL) |
53 |
|
return(0); |
54 |
|
lastp = NULL; |
55 |
|
while (fgets(buf, sizeof(buf), fp) != NULL) { |
93 |
|
goto fmterr; |
94 |
|
} |
95 |
|
} else { /* or read specificaion */ |
96 |
< |
if ((lp->color=(float *)malloc(3*sizeof(float)))==NULL) |
96 |
> |
if ((lp->color=(float *)malloc(6*sizeof(float)))==NULL) |
97 |
|
goto memerr; |
98 |
< |
if (sscanf(cp1, "%f %f %f", &lp->color[0], & |
99 |
< |
lp->color[1], &lp->color[2]) != 3) { |
98 |
> |
if (sscanf(cp1, "%f %f %f", &lp->color[3], & |
99 |
> |
lp->color[4], &lp->color[5]) != 3) { |
100 |
|
cp1 = "bad lamp data"; |
101 |
|
goto fmterr; |
102 |
|
} |
103 |
|
/* convert xyY to XYZ */ |
104 |
< |
xyz[1] = lp->color[2]; |
105 |
< |
xyz[0] = lp->color[0]/lp->color[1] * xyz[1]; |
106 |
< |
xyz[2] = xyz[1]*(1./lp->color[1] - 1.) - xyz[0]; |
104 |
> |
xyz[1] = lp->color[5]; |
105 |
> |
xyz[0] = lp->color[3]/lp->color[4] * xyz[1]; |
106 |
> |
xyz[2] = xyz[1]*(1./lp->color[4] - 1.) - xyz[0]; |
107 |
|
/* XYZ to RGB */ |
108 |
|
cie_rgb(lp->color, xyz); |
109 |
|
} |