| 128 |
|
static void getpicture(void); |
| 129 |
|
static void getcolors(void); |
| 130 |
|
static void bresp(COLOR y, COLOR x); |
| 131 |
+ |
static void ibresp(COLOR y, COLOR x); |
| 132 |
|
static void compute(void); |
| 133 |
|
static void putmapping(void); |
| 134 |
|
static void compsoln(COLOR cin[], COLOR cout[], int n); |
| 435 |
|
|
| 436 |
|
static void |
| 437 |
|
bresp( /* piecewise linear interpolation of primaries */ |
| 438 |
< |
COLOR y, |
| 439 |
< |
COLOR x |
| 438 |
> |
COLOR y, /* y is linear output */ |
| 439 |
> |
COLOR x /* x is non-linear input */ |
| 440 |
|
) |
| 441 |
|
{ |
| 442 |
|
int i, n; |
| 455 |
|
|
| 456 |
|
|
| 457 |
|
static void |
| 458 |
+ |
ibresp( /* inverse mapping (delinearization) */ |
| 459 |
+ |
COLOR x, /* x is non-linear output */ |
| 460 |
+ |
COLOR y /* y is linear input */ |
| 461 |
+ |
) |
| 462 |
+ |
{ |
| 463 |
+ |
int i, n; |
| 464 |
+ |
|
| 465 |
+ |
for (i = 0; i < 3; i++) { |
| 466 |
+ |
for (n = 0; n < NMBNEU-2; n++) |
| 467 |
+ |
if (colval(y,i) < colval(bramp[n+1][1],i)) |
| 468 |
+ |
break; |
| 469 |
+ |
colval(x,i) = ((colval(bramp[n+1][1],i) - colval(y,i)) * |
| 470 |
+ |
colval(bramp[n][0],i) + |
| 471 |
+ |
(colval(y,i) - colval(bramp[n][1],i)) * |
| 472 |
+ |
colval(bramp[n+1][0],i)) / |
| 473 |
+ |
(colval(bramp[n+1][1],i) - colval(bramp[n][1],i)); |
| 474 |
+ |
} |
| 475 |
+ |
} |
| 476 |
+ |
|
| 477 |
+ |
|
| 478 |
+ |
static void |
| 479 |
|
compute(void) /* compute color mapping */ |
| 480 |
|
{ |
| 481 |
|
COLOR clrin[24], clrout[24]; |
| 501 |
|
copycolor(bramp[i][1], mbRGB[mbneu[i]]); |
| 502 |
|
} |
| 503 |
|
/* compute color space gamut */ |
| 504 |
< |
if (scanning) { |
| 505 |
< |
copycolor(colmin, cblack); |
| 506 |
< |
copycolor(colmax, cwhite); |
| 507 |
< |
scalecolor(colmax, irrad); |
| 508 |
< |
} else |
| 509 |
< |
for (i = 0; i < 3; i++) { |
| 510 |
< |
colval(colmin,i) = colval(bramp[0][0],i) - |
| 489 |
< |
colval(bramp[0][1],i) * |
| 490 |
< |
(colval(bramp[1][0],i)-colval(bramp[0][0],i)) / |
| 491 |
< |
(colval(bramp[1][1],i)-colval(bramp[0][1],i)); |
| 492 |
< |
colval(colmax,i) = colval(bramp[NMBNEU-2][0],i) + |
| 493 |
< |
(1.-colval(bramp[NMBNEU-2][1],i)) * |
| 494 |
< |
(colval(bramp[NMBNEU-1][0],i) - |
| 495 |
< |
colval(bramp[NMBNEU-2][0],i)) / |
| 496 |
< |
(colval(bramp[NMBNEU-1][1],i) - |
| 497 |
< |
colval(bramp[NMBNEU-2][1],i)); |
| 498 |
< |
} |
| 504 |
> |
copycolor(colmin, cblack); |
| 505 |
> |
copycolor(colmax, cwhite); |
| 506 |
> |
scalecolor(colmax, irrad); |
| 507 |
> |
if (!scanning) { |
| 508 |
> |
ibresp(colmin, colmin); |
| 509 |
> |
ibresp(colmax, colmax); |
| 510 |
> |
} |
| 511 |
|
/* compute color mapping */ |
| 512 |
|
do { |
| 513 |
|
cflags = inpflags & ~gmtflags; |
| 514 |
|
n = 0; /* compute transform matrix */ |
| 515 |
< |
for (i = 0; i < 24; i++) |
| 516 |
< |
if (cflags & 1L<<i) { |
| 515 |
> |
for (i = 0; i < 24; i++) { |
| 516 |
> |
if (!(cflags & 1L<<i)) |
| 517 |
> |
continue; |
| 518 |
> |
if (scanning) { |
| 519 |
|
bresp(clrin[n], inpRGB[i]); |
| 520 |
|
copycolor(clrout[n], mbRGB[i]); |
| 521 |
< |
n++; |
| 521 |
> |
} else { |
| 522 |
> |
copycolor(clrin[n], inpRGB[i]); |
| 523 |
> |
ibresp(clrout[n], mbRGB[i]); |
| 524 |
|
} |
| 525 |
+ |
n++; |
| 526 |
+ |
} |
| 527 |
|
compsoln(clrin, clrout, n); |
| 528 |
|
for (i = 0; i < 24; i++) /* check gamut */ |
| 529 |
|
if (cflags & 1L<<i && cvtcolor(ctmp, inpRGB[i])) |
| 530 |
|
gmtflags |= 1L<<i; |
| 531 |
|
} while (cflags & gmtflags); |
| 532 |
+ |
|
| 533 |
|
if (gmtflags & MODFLGS) |
| 534 |
|
fprintf(stderr, |
| 535 |
|
"%s: warning - some moderate colors are out of gamut\n", |