| 396 |
|
void /* add sources smaller than rad to computed subimage */ |
| 397 |
|
drawsources( |
| 398 |
|
COLORV *pic[], /* subimage pixel value array */ |
| 399 |
+ |
RGBPRIMP primp, /* output primaries */ |
| 400 |
|
float *zbf[], /* subimage distance array (opt.) */ |
| 401 |
|
int x0, /* origin and size of subimage */ |
| 402 |
|
int xsiz, |
| 404 |
|
int ysiz |
| 405 |
|
) |
| 406 |
|
{ |
| 407 |
< |
RREAL spoly[MAXVERT][2], ppoly[MAXVERT][2]; |
| 408 |
< |
int nsv, npv; |
| 409 |
< |
int xmin, xmax, ymin, ymax, x, y; |
| 410 |
< |
RREAL cxy[2]; |
| 411 |
< |
double w; |
| 412 |
< |
RAY sr; |
| 413 |
< |
SPLIST *sp; |
| 414 |
< |
int i; |
| 407 |
> |
const int NC = primp ? 3 : NCSAMP; |
| 408 |
> |
RREAL spoly[MAXVERT][2], ppoly[MAXVERT][2]; |
| 409 |
> |
int nsv, npv; |
| 410 |
> |
int xmin, xmax, ymin, ymax, x, y; |
| 411 |
> |
RREAL cxy[2]; |
| 412 |
> |
COLOR rcol; |
| 413 |
> |
double w; |
| 414 |
> |
RAY sr; |
| 415 |
> |
SPLIST *sp; |
| 416 |
> |
int i; |
| 417 |
|
/* check each source in our list */ |
| 418 |
|
for (sp = sphead; sp != NULL; sp = sp->next) { |
| 419 |
|
/* clip source poly to subimage */ |
| 437 |
|
} |
| 438 |
|
/* evaluate each pixel in BBox */ |
| 439 |
|
for (y = ymin; y <= ymax; y++) { |
| 440 |
< |
COLORV *pp = pic[y-y0] + (xmin-x0)*NCSAMP; |
| 441 |
< |
for (x = xmin; x <= xmax; x++, pp += NCSAMP) { |
| 440 |
> |
COLORV *pp = pic[y-y0] + (xmin-x0)*NC; |
| 441 |
> |
for (x = xmin; x <= xmax; x++, pp += NC) { |
| 442 |
|
/* subarea for pixel */ |
| 443 |
|
npv = box_clip_poly(spoly, nsv, |
| 444 |
|
(double)x/hres, (x+1.)/hres, |
| 458 |
|
rayvalue(&sr); /* compute value */ |
| 459 |
|
if (sintens(sr.rcol) <= FTINY) |
| 460 |
|
continue; /* missed/blocked */ |
| 461 |
+ |
if (NC == 3) |
| 462 |
+ |
scolor_out(rcol, primp, sr.rcol); |
| 463 |
|
/* modify pixel */ |
| 464 |
|
w = poly_area(ppoly, npv) * hres * vres; |
| 465 |
|
if (zbf[y-y0] != NULL && |
| 466 |
|
sr.rxt < 0.99*zbf[y-y0][x-x0]) { |
| 467 |
|
zbf[y-y0][x-x0] = sr.rxt; |
| 468 |
< |
} else if (!sbigsdiff(sr.rcol, pp, 0.01)) { /* source sample */ |
| 468 |
> |
} else if (NC == 3) { |
| 469 |
> |
if (!bigdiff(rcol, pp, 0.07)) { |
| 470 |
> |
scalecolor(pp, w); |
| 471 |
> |
continue; |
| 472 |
> |
} |
| 473 |
> |
} else if (!sbigsdiff(sr.rcol, pp, 0.07)) { |
| 474 |
|
scalescolor(pp, w); |
| 475 |
|
continue; |
| 476 |
|
} |
| 477 |
< |
scalescolor(sr.rcol, w); |
| 478 |
< |
scalescolor(pp, 1.-w); |
| 479 |
< |
saddscolor(pp, sr.rcol); |
| 477 |
> |
if (NC == 3) { |
| 478 |
> |
scalecolor(rcol, w); |
| 479 |
> |
scalecolor(pp, 1.-w); |
| 480 |
> |
addcolor(pp, rcol); |
| 481 |
> |
} else { |
| 482 |
> |
scalescolor(sr.rcol, w); |
| 483 |
> |
scalescolor(pp, 1.-w); |
| 484 |
> |
saddscolor(pp, sr.rcol); |
| 485 |
> |
} |
| 486 |
|
} |
| 487 |
|
} |
| 488 |
|
} |