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 */ |
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 |
< |
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()"); |
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)*nc; |
441 |
< |
for (x = xmin; x <= xmax; x++, pp += nc) { |
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_rgb(rcol, sr.rcol); |
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 (nc == 3) { |
468 |
> |
} else if (NC == 3) { |
469 |
|
if (!bigdiff(rcol, pp, 0.07)) { |
470 |
|
scalecolor(pp, w); |
471 |
|
continue; |
474 |
|
scalescolor(pp, w); |
475 |
|
continue; |
476 |
|
} |
477 |
< |
if (nc == 3) { |
477 |
> |
if (NC == 3) { |
478 |
|
scalecolor(rcol, w); |
479 |
|
scalecolor(pp, 1.-w); |
480 |
|
addcolor(pp, rcol); |