--- ray/src/common/spec_rgb.c 2006/09/05 21:54:32 2.15 +++ ray/src/common/spec_rgb.c 2010/01/04 19:40:14 2.20 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: spec_rgb.c,v 2.15 2006/09/05 21:54:32 greg Exp $"; +static const char RCSid[] = "$Id: spec_rgb.c,v 2.20 2010/01/04 19:40:14 greg Exp $"; #endif /* * Convert colors and spectral ranges. @@ -241,14 +241,21 @@ colorprimsOK( /* are color primaries reasonable? */ RGBPRIMS pr ) { - int i; + int i, j; for (i = 0; i < 4; i++) { - if ((pr[i][CIEX] <= CEPS) | (pr[i][CIEY] <= CEPS)) + if ((pr[i][CIEX] <= -.5) | (pr[i][CIEY] <= -.5)) return(0); - if ((pr[i][CIEX] >= 1.-CEPS) | (pr[i][CIEY] >= 1.-CEPS)) + if ((pr[i][CIEX] >= 1.5) | (pr[i][CIEY] >= 1.5)) return(0); + if (pr[i][CIEX] + pr[i][CIEY] >= 1.5) + return(0); } + for (i = 0; i < 4; i++) + for (j = i+1; j < 4; j++) + if (CEQ(pr[i][CIEX],pr[j][CIEX]) && + CEQ(pr[i][CIEY],pr[j][CIEY])) + return(0); return(1); } @@ -264,7 +271,7 @@ register RGBPRIMS pr if (pr == stdprims) { /* can use xyz2rgbmat */ cpcolormat(mat, xyz2rgbmat); - return; + return(1); } if (CEQ(pr[WHT][CIEX],0.) | CEQ(pr[WHT][CIEY],0.)) return(0); @@ -324,7 +331,7 @@ register RGBPRIMS pr if (pr == stdprims) { /* can use rgb2xyzmat */ cpcolormat(mat, rgb2xyzmat); - return; + return(1); } if (CEQ(pr[WHT][CIEX],0.) | CEQ(pr[WHT][CIEY],0.)) return(0); @@ -371,7 +378,7 @@ RGBPRIMS pr2 mat[0][0] = mat[1][1] = mat[2][2] = 1.0; mat[0][1] = mat[0][2] = mat[1][0] = mat[1][2] = mat[2][0] = mat[2][1] = 0.0; - return; + return(1); } if (!comprgb2xyzmat(pr1toxyz, pr1)) return(0);