--- ray/src/common/spec_rgb.c 2007/10/08 18:07:55 2.16 +++ ray/src/common/spec_rgb.c 2012/05/18 22:48:39 2.24 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: spec_rgb.c,v 2.16 2007/10/08 18:07:55 greg Exp $"; +static const char RCSid[] = "$Id: spec_rgb.c,v 2.24 2012/05/18 22:48:39 greg Exp $"; #endif /* * Convert colors and spectral ranges. @@ -38,7 +38,7 @@ float xyneu[2] = {1./3., 1./3.}; /* neutral xy chroma #define INCWL 10 /* wavelength increment */ #define NINC 40 /* # of values */ -static BYTE chroma[3][NINC] = { +static uby8 chroma[3][NINC] = { { /* X */ 0, 0, 0, 2, 6, 13, 22, 30, 36, 41, 42, 43, 43, 44, 46, 52, 60, 71, 87, 106, @@ -241,14 +241,26 @@ 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)) + for (i = 0; i < 3; i++) { + if ((pr[i][CIEX] <= -2.) | (pr[i][CIEY] <= -2.)) return(0); - if ((pr[i][CIEX] >= 1.-CEPS) | (pr[i][CIEY] >= 1.-CEPS)) + if ((pr[i][CIEX] >= 3.) | (pr[i][CIEY] >= 3.)) return(0); + if (pr[i][CIEX] + pr[i][CIEY] <= -2.) + return(0); + if (pr[i][CIEX] + pr[i][CIEY] >= 3.) + return(0); } + if ((pr[3][CIEX] <= 0.) | (pr[3][CIEX] >= 1.) | + (pr[3][CIEY] <= 0.) | (pr[3][CIEY] >= 1.)) + 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); }