50 |
|
scolor_out(col, primp, rp->rcol); |
51 |
|
return SetPixel(x, y, col, zv); |
52 |
|
default: |
53 |
< |
error(INTERNAL, "missing color space type in SetPixel()"); |
53 |
> |
error(INTERNAL, "botched color space type in SetPixel()"); |
54 |
|
} |
55 |
|
return false; |
56 |
|
} |
79 |
|
case RDTrgb: |
80 |
|
primp = pr ? pr : stdprims; |
81 |
|
break; |
82 |
< |
default: // RDTscolr | RDTscolor |
82 |
> |
case RDTscolr: |
83 |
> |
case RDTscolor: |
84 |
|
primp = NULL; |
85 |
|
break; |
86 |
+ |
default: |
87 |
+ |
error(INTERNAL, "botched color space type in SetColorSpace()"); |
88 |
|
} |
89 |
|
dtyp = RDTnewCT(dtyp, cs); |
87 |
– |
if (primp) |
88 |
– |
xyz2myrgbmat[0][0] = 0; |
90 |
|
return true; |
91 |
|
} |
92 |
|
|
139 |
|
RpictSimulManager::RtCall(RAY *r, void *cd) |
140 |
|
{ |
141 |
|
RpictSimulManager * rsp = (RpictSimulManager *)cd; |
142 |
< |
const int ty = r->rno / rsp->TWidth(); |
143 |
< |
const int tx = r->rno - (RNUMBER)ty*rsp->TWidth(); |
142 |
> |
const int ty = (r->rno-1) / rsp->TWidth(); |
143 |
> |
const int tx = r->rno-1 - (RNUMBER)ty*rsp->TWidth(); |
144 |
|
|
145 |
|
if (ty >= rsp->THeight()) { |
146 |
|
error(INTERNAL, "bad pixel calculation position in RtCall()"); |
228 |
|
for (i = (dlim > FTINY)*3; i--; ) |
229 |
|
rodir[1][i] *= dlim; |
230 |
|
|
231 |
< |
return EnqueueRay(rodir[0], rodir[1], (RNUMBER)y*TWidth()+x); |
231 |
> |
return EnqueueRay(rodir[0], rodir[1], (RNUMBER)y*TWidth()+x+1); |
232 |
|
} |
233 |
|
|
234 |
|
// Check if neighbor differences are below pixel sampling threshold |
262 |
|
|
263 |
|
// Fill an interior square patch with interpolated values |
264 |
|
void |
265 |
< |
RpictSimulManager::FillSquare(int x, int y, const int noff[4][2]) |
265 |
> |
RpictSimulManager::FillSquare(const int x, const int y, const int noff[4][2]) |
266 |
|
{ |
267 |
|
SCOLOR pval[4]; |
268 |
|
float dist[4]; |
272 |
|
pacc.GetPixel(x+noff[i][0], y+noff[i][1], pval[i], &dist[i]); |
273 |
|
|
274 |
|
i = abs(noff[1][0]-noff[0][0]); |
275 |
< |
j = abs(noff[1][1]-noff[0][1]); |
276 |
< |
const int slen = i > j ? i : j; |
276 |
< |
const double sf = 1./slen; |
275 |
> |
j = abs(noff[1][1]-noff[0][1]); // i==j for diamond fill |
276 |
> |
const int slen = (i > j) ? i : j; |
277 |
|
const bool spectr = (pacc.NC() > 3); |
278 |
< |
for (i = 0; i <= slen; i++) { // bilinear interpolant |
279 |
< |
const double c1 = i*sf; |
280 |
< |
for (j = 0; j <= slen; j++) { |
281 |
< |
const double c2 = j*sf; |
278 |
> |
for (i = slen+1 + (i==j)*slen; i--; ) { |
279 |
> |
const double c1 = (i>slen ? i-slen-.5 : (double)i)/slen; |
280 |
> |
for (j = slen + (i<=slen); j--; ) { |
281 |
> |
const double c2 = (j + (i>slen)*.5)/slen; |
282 |
|
const int px = int(x + (1.-c1)*(1.-c2)*noff[0][0] + |
283 |
|
c1*(1.-c2)*noff[1][0] + |
284 |
|
(1.-c1)*c2*noff[2][0] + |
331 |
|
SetQuincunx(ABitMap2 *bmp2, int noff[4][2], const int spc, const bool odd) |
332 |
|
{ |
333 |
|
for (int y = 0; y < bmp2->Height(); y += spc>>1) |
334 |
< |
for (int x = odd*(spc>>1); x < bmp2->Width(); x += spc) |
334 |
> |
for (int x = (odd^(y&1))*(spc>>1); x < bmp2->Width(); x += spc) |
335 |
|
bmp2->Set(x, y); |
336 |
|
// order neighbors CCW |
337 |
|
if (odd) { |
370 |
|
sampMap -= doneSamples; // avoid resampling pixels |
371 |
|
// Are we into adaptive sampling realm? |
372 |
|
if (noff[0][0]*noff[0][0] + noff[0][1]*noff[0][1] < psample*psample) { |
373 |
< |
if (FlushQueue() < 0) // need results to check threshold |
373 |
> |
if (FlushQueue() < 0) // need results to check thresholds |
374 |
|
return false; |
375 |
|
ABitMap2 fillMap = sampMap; |
376 |
|
for (x = y = 0; sampMap.Find(&x, &y); x++) |
378 |
|
sampMap.Reset(x, y); |
379 |
|
// spread sampling to neighbors... |
380 |
|
const ABitMap2 origSampMap = sampMap; |
381 |
< |
for (int yoff = -(1<<(sp2-1)); |
382 |
< |
yoff <= 1<<(sp2-1); yoff += 1<<sp2) |
383 |
< |
for (int xoff = -(1<<(sp2-1)); |
384 |
< |
xoff <= 1<<(sp2-1); xoff += 1<<sp2) { |
381 |
> |
for (x = 4; x--; ) { |
382 |
|
ABitMap2 stamp = origSampMap; |
383 |
< |
stamp.Shift(xoff, yoff); |
383 |
> |
stamp.Shift(noff[x][0], noff[x][1]); |
384 |
|
sampMap |= stamp; |
385 |
|
} // ...but don't resample what's done |
386 |
|
sampMap -= doneSamples; |
506 |
|
if (v <= 0) return !v; |
507 |
|
if (!barPix | !barDepth | (v > THeight()) | !tvw.type) |
508 |
|
return false; |
509 |
< |
tvw.voff -= double(v)/GetHeight(); |
510 |
< |
ptvw.voff -= double(v)/GetHeight(); |
509 |
> |
tvw.voff -= double(v)/THeight(); |
510 |
> |
ptvw.voff -= double(v)/THeight(); |
511 |
|
if (v == THeight()) { |
512 |
|
doneMap.ClearBitMap(); |
513 |
|
return true; |
559 |
|
} |
560 |
|
int lastOut = ytop; // render down frame |
561 |
|
while (ytop > 0) { |
562 |
+ |
fprintf(stderr, "At y=%d, source drawing %s...\n", ytop, parr ? "ON" : "OFF"); |
563 |
|
if (ytop < THeight()) // mark what we won't do as finished |
564 |
|
doneMap.ClearRect(0, 0, TWidth(), THeight()-ytop, true); |
565 |
|
if (prCB) |
603 |
|
error(SYSTEM, "cannot write SCOLOR output"); |
604 |
|
break; |
605 |
|
default: |
606 |
< |
error(INTERNAL, "missing output color type in RenderBelow()"); |
606 |
> |
error(INTERNAL, "botched output color type in RenderBelow()"); |
607 |
|
break; |
608 |
|
} |
609 |
|
bpos += pacc.NC()*TWidth(); |
627 |
|
* Render and write a frame to the named file |
628 |
|
* Include any header lines set prior to call |
629 |
|
* Picture file must not already exist |
630 |
< |
* Picture to stdout if pfname==NULL |
631 |
< |
* Depth written to a command if dfname[0]=='!' |
630 |
> |
* Write pixels to stdout if !pfname |
631 |
> |
* Write depth to a command if dfname[0]=='!' |
632 |
|
*/ |
633 |
|
RenderDataType |
634 |
|
RpictSimulManager::RenderFrame(const char *pfname, RenderDataType dt, const char *dfname) |
638 |
|
FILE * dfp = NULL; |
639 |
|
|
640 |
|
if (!RDTcolorT(dt)) |
641 |
< |
error(INTERNAL, "missing pixel output type in RenderFrame()"); |
641 |
> |
error(INTERNAL, "botched color output type in RenderFrame()"); |
642 |
|
if (NCSAMP == 3) { |
643 |
|
if (RDTcolorT(dt) == RDTscolr) |
644 |
|
dt = RDTnewCT(dt, prims==xyzprims ? RDTxyze : RDTrgbe); |
674 |
|
if (frameNo > 0) |
675 |
|
fprintf(pfp, "FRAME=%d\n", frameNo); |
676 |
|
double pasp = viewaspect(&vw) * GetWidth() / GetHeight(); |
677 |
< |
if (!FABSEQ(pasp, 1.0)) |
677 |
> |
if ((0.99 > pasp) | (pasp > 1.01)) |
678 |
|
fputaspect(pasp, pfp); |
679 |
|
fputnow(pfp); |
680 |
|
switch (RDTcolorT(dt)) { // set primaries and picture format |