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