| 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 */ | 
| 38 | 
  | 
#define  INCWL          10              /* wavelength increment */ | 
| 39 | 
  | 
#define  NINC           40              /* # of values */ | 
| 40 | 
  | 
 | 
| 41 | 
< | 
static BYTE  chroma[3][NINC] = { | 
| 41 | 
> | 
static uby8  chroma[3][NINC] = { | 
| 42 | 
  | 
        {                                                       /* X */ | 
| 43 | 
  | 
                0,   0,   0,   2,   6,   13,  22,  30,  36,  41, | 
| 44 | 
  | 
                42,  43,  43,  44,  46,  52,  60,  71,  87,  106, | 
| 111 | 
  | 
int  e | 
| 112 | 
  | 
) | 
| 113 | 
  | 
{ | 
| 114 | 
< | 
        register int  i, d, r; | 
| 114 | 
> | 
        int  i, d, r; | 
| 115 | 
  | 
         | 
| 116 | 
  | 
        s -= STARTWL; | 
| 117 | 
  | 
        if (s < 0) | 
| 164 | 
  | 
        int  rflags = 0; | 
| 165 | 
  | 
        double  brtmin, brtmax, v, vv; | 
| 166 | 
  | 
        COLOR  cgry; | 
| 167 | 
< | 
        register int  i; | 
| 167 | 
> | 
        int  i; | 
| 168 | 
  | 
                                        /* check for no check */ | 
| 169 | 
  | 
        if (gamut == 0) return(0); | 
| 170 | 
  | 
                                        /* check brightness limits */ | 
| 202 | 
  | 
 | 
| 203 | 
  | 
void | 
| 204 | 
  | 
colortrans(                     /* convert c1 by mat and put into c2 */ | 
| 205 | 
< | 
register COLOR  c2, | 
| 206 | 
< | 
register COLORMAT  mat, | 
| 207 | 
< | 
register COLOR  c1 | 
| 205 | 
> | 
COLOR  c2, | 
| 206 | 
> | 
COLORMAT  mat, | 
| 207 | 
> | 
COLOR  c1 | 
| 208 | 
  | 
) | 
| 209 | 
  | 
{ | 
| 210 | 
  | 
        COLOR   cout; | 
| 225 | 
  | 
) | 
| 226 | 
  | 
{ | 
| 227 | 
  | 
        COLORMAT  mt; | 
| 228 | 
< | 
        register int  i, j; | 
| 228 | 
> | 
        int  i, j; | 
| 229 | 
  | 
 | 
| 230 | 
  | 
        for (i = 0; i < 3; i++) | 
| 231 | 
  | 
                for (j = 0; j < 3; j++) | 
| 241 | 
  | 
RGBPRIMS  pr | 
| 242 | 
  | 
) | 
| 243 | 
  | 
{ | 
| 244 | 
< | 
        int     i; | 
| 245 | 
< | 
         | 
| 246 | 
< | 
        for (i = 0; i < 4; i++) { | 
| 247 | 
< | 
                if ((pr[i][CIEX] <= -.5 | (pr[i][CIEY] <= -.5)) | 
| 244 | 
> | 
        int     i, j; | 
| 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); | 
| 258 | 
< | 
                if ((pr[i][CIEX] >= 1.5) | (pr[i][CIEY] >= 1.5)) | 
| 258 | 
> | 
                if ((pr[i][CIEX] >= 3.) | (pr[i][CIEY] >= 3.)) | 
| 259 | 
  | 
                        return(0); | 
| 260 | 
< | 
                if (pr[i][CIEX] + pr[i][CIEY] >= 1.5) | 
| 260 | 
> | 
                if (pr[i][CIEX] + pr[i][CIEY] <= -2.) | 
| 261 | 
  | 
                        return(0); | 
| 262 | 
+ | 
                if (pr[i][CIEX] + pr[i][CIEY] >= 3.) | 
| 263 | 
+ | 
                        return(0); | 
| 264 | 
  | 
        } | 
| 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]) & | 
| 268 | 
+ | 
                                        CEQ(pr[i][CIEY],pr[j][CIEY])) | 
| 269 | 
+ | 
                                return(0); | 
| 270 | 
  | 
        return(1); | 
| 271 | 
  | 
} | 
| 272 | 
  | 
 | 
| 275 | 
  | 
int | 
| 276 | 
  | 
compxyz2rgbmat(                 /* compute conversion from CIE to RGB space */ | 
| 277 | 
  | 
COLORMAT  mat, | 
| 278 | 
< | 
register RGBPRIMS  pr | 
| 278 | 
> | 
RGBPRIMS  pr | 
| 279 | 
  | 
) | 
| 280 | 
  | 
{ | 
| 281 | 
  | 
        double  C_rD, C_gD, C_bD; | 
| 335 | 
  | 
int | 
| 336 | 
  | 
comprgb2xyzmat(                 /* compute conversion from RGB to CIE space */ | 
| 337 | 
  | 
COLORMAT  mat, | 
| 338 | 
< | 
register RGBPRIMS  pr | 
| 338 | 
> | 
RGBPRIMS  pr | 
| 339 | 
  | 
) | 
| 340 | 
  | 
{ | 
| 341 | 
  | 
        double  C_rD, C_gD, C_bD, D; |