16 |
|
|
17 |
|
#define CEPS 1e-4 /* color epsilon */ |
18 |
|
|
19 |
< |
#define CEQ(v1,v2) ((v1) <= (v2)+CEPS && (v2) <= (v1)+CEPS) |
19 |
> |
#define CEQ(v1,v2) (((v1) <= (v2)+CEPS) & ((v2) <= (v1)+CEPS)) |
20 |
|
|
21 |
< |
#define XYEQ(c1,c2) (CEQ((c1)[CIEX],(c2)[CIEX]) && CEQ((c1)[CIEY],(c2)[CIEY])) |
21 |
> |
#define XYEQ(c1,c2) (CEQ((c1)[CIEX],(c2)[CIEX]) & CEQ((c1)[CIEY],(c2)[CIEY])) |
22 |
|
|
23 |
|
|
24 |
|
RGBPRIMS stdprims = STDPRIMS; /* standard primary chromaticities */ |
242 |
|
) |
243 |
|
{ |
244 |
|
int i, j; |
245 |
< |
|
245 |
> |
/* check white point */ |
246 |
> |
if ((pr[3][CIEX] <= CEPS) | (pr[3][CIEX] >= 1.-CEPS) | |
247 |
> |
(pr[3][CIEY] <= CEPS) | (pr[3][CIEY] >= 1.-CEPS)) |
248 |
> |
return(0); |
249 |
> |
for (i = 3; i--; ) /* check for XYZ color primaries */ |
250 |
> |
if (!CEQ(pr[i][CIEX],(i==0)) | !CEQ(pr[i][CIEY],(i==1))) |
251 |
> |
break; |
252 |
> |
if (i < 0) |
253 |
> |
return(-1); /* flag as XYZ color space */ |
254 |
> |
/* check color primaries */ |
255 |
|
for (i = 0; i < 3; i++) { |
256 |
|
if ((pr[i][CIEX] <= -2.) | (pr[i][CIEY] <= -2.)) |
257 |
|
return(0); |
262 |
|
if (pr[i][CIEX] + pr[i][CIEY] >= 3.) |
263 |
|
return(0); |
264 |
|
} |
265 |
< |
if ((pr[3][CIEX] <= 0.) | (pr[3][CIEX] >= 1.) | |
257 |
< |
(pr[3][CIEY] <= 0.) | (pr[3][CIEY] >= 1.)) |
258 |
< |
return(0); |
259 |
< |
for (i = 0; i < 4; i++) |
265 |
> |
for (i = 0; i < 4; i++) /* make sure space is 3-dimensional */ |
266 |
|
for (j = i+1; j < 4; j++) |
267 |
< |
if (CEQ(pr[i][CIEX],pr[j][CIEX]) && |
267 |
> |
if (CEQ(pr[i][CIEX],pr[j][CIEX]) & |
268 |
|
CEQ(pr[i][CIEY],pr[j][CIEY])) |
269 |
|
return(0); |
270 |
|
return(1); |