| 27 |
|
#define RDTcolorT(f) RenderDataType((f) & RDTcolorM) |
| 28 |
|
#define RDTdepthT(f) RenderDataType((f) & RDTdepthM) |
| 29 |
|
#define RDTcommonE(f) (RDTcolorT(f) >= RDTscolr) |
| 30 |
< |
#define RDTnewCT(f,c) RenderDataType((f) & ~RDTcolorM | (c)) |
| 31 |
< |
#define RDTnewDT(f,d) RenderDataType((f) & ~RDTdepthM | (d)) |
| 30 |
> |
#define RDTnewCT(f,c) RenderDataType((f) & ~RDTcolorM | (c) & RDTcolorM) |
| 31 |
> |
#define RDTnewDT(f,d) RenderDataType((f) & ~RDTdepthM | (d) & RDTdepthM) |
| 32 |
|
|
| 33 |
|
/// Pixel accessor (read/write to caller's buffer with possible conversion) |
| 34 |
|
class PixelAccess { |
| 43 |
|
long rowStride; // # values to next y position |
| 44 |
|
int dtyp; // data type flags |
| 45 |
|
RGBPRIMP primp; // color primaries if tristimulus |
| 46 |
< |
COLORMAT xyz2myrgbmat; // custom color conversion matrix |
| 46 |
> |
const COLORV * CF3(int x, int y) const { |
| 47 |
> |
return pbase.f + (rowStride*y + x)*3; |
| 48 |
> |
} |
| 49 |
|
COLORV * CF3(int x, int y) { |
| 50 |
|
return pbase.f + (rowStride*y + x)*3; |
| 51 |
|
} |
| 52 |
< |
COLORV * GetCF3(int x, int y) const { |
| 53 |
< |
return const_cast<COLORV *>(pbase.f + (rowStride*y + x)*3); |
| 52 |
> |
const COLRV * CB3(int x, int y) const { |
| 53 |
> |
return pbase.b + (rowStride*y + x)*4; |
| 54 |
|
} |
| 53 |
– |
COLORV * SCF(int x, int y) { |
| 54 |
– |
return pbase.f + (rowStride*y + x)*NCSAMP; |
| 55 |
– |
} |
| 56 |
– |
COLORV * GetSCF(int x, int y) const { |
| 57 |
– |
return const_cast<COLORV *>(pbase.f + (rowStride*y + x)*NCSAMP); |
| 58 |
– |
} |
| 55 |
|
COLRV * CB3(int x, int y) { |
| 56 |
|
return pbase.b + (rowStride*y + x)*4; |
| 57 |
|
} |
| 58 |
< |
COLRV * GetCB3(int x, int y) const { |
| 59 |
< |
return const_cast<COLRV *>(pbase.b + (rowStride*y + x)*4); |
| 58 |
> |
const COLORV * SCF(int x, int y) const { |
| 59 |
> |
return pbase.f + (rowStride*y + x)*NCSAMP; |
| 60 |
|
} |
| 61 |
+ |
COLORV * SCF(int x, int y) { |
| 62 |
+ |
return pbase.f + (rowStride*y + x)*NCSAMP; |
| 63 |
+ |
} |
| 64 |
+ |
const COLRV * SCB(int x, int y) const { |
| 65 |
+ |
return pbase.b + (rowStride*y + x)*(NCSAMP+1); |
| 66 |
+ |
} |
| 67 |
|
COLRV * SCB(int x, int y) { |
| 68 |
|
return pbase.b + (rowStride*y + x)*(NCSAMP+1); |
| 69 |
|
} |
| 68 |
– |
COLRV * GetSCB(int x, int y) const { |
| 69 |
– |
return const_cast<COLRV *>(pbase.b + (rowStride*y + x)*(NCSAMP+1)); |
| 70 |
– |
} |
| 70 |
|
public: |
| 71 |
|
double refDepth; // reference depth |
| 72 |
|
PixelAccess() { |
| 175 |
|
bool GetPixel(int x, int y, COLORV *pv, float *zp=NULL) const { |
| 176 |
|
if (NC() == 3) { |
| 177 |
|
if (RDTcommonE(dtyp)) |
| 178 |
< |
colr_color(pv, GetCB3(x,y)); |
| 178 |
> |
colr_color(pv, CB3(x,y)); |
| 179 |
|
else |
| 180 |
< |
copycolor(pv, GetCF3(x,y)); |
| 180 |
> |
copycolor(pv, CF3(x,y)); |
| 181 |
|
} else if (RDTcommonE(dtyp)) |
| 182 |
< |
scolr_scolor(pv, GetSCB(x,y)); |
| 182 |
> |
scolr_scolor(pv, SCB(x,y)); |
| 183 |
|
else |
| 184 |
< |
copyscolor(pv, GetSCF(x,y)); |
| 184 |
> |
copyscolor(pv, SCF(x,y)); |
| 185 |
|
if (!zp) return true; |
| 186 |
|
if (RDTdepthT(dtyp) == RDTdfloat) |
| 187 |
|
*zp = dbase.f[rowStride*y + x]; |
| 197 |
|
const int nc = NC(); |
| 198 |
|
if (nc == 3) { |
| 199 |
|
if (RDTcommonE(dtyp)) |
| 200 |
< |
copycolr(CB3(dx,dy), GetCB3(sx,sy)); |
| 200 |
> |
copycolr(CB3(dx,dy), CB3(sx,sy)); |
| 201 |
|
else |
| 202 |
< |
copycolor(CF3(dx,dy), GetCF3(sx,sy)); |
| 202 |
> |
copycolor(CF3(dx,dy), CF3(sx,sy)); |
| 203 |
|
} else if (RDTcommonE(dtyp)) |
| 204 |
< |
copyscolr(SCB(dx,dy), GetSCB(sx,sy)); |
| 204 |
> |
copyscolr(SCB(dx,dy), SCB(sx,sy)); |
| 205 |
|
else |
| 206 |
< |
copyscolor(SCF(dx,dy), GetSCF(sx,sy)); |
| 206 |
> |
copyscolor(SCF(dx,dy), SCF(sx,sy)); |
| 207 |
|
switch (RDTdepthT(dtyp)) { |
| 208 |
|
case RDTdfloat: |
| 209 |
|
dbase.f[rowStride*dy + dx] = |
| 240 |
|
bool RenderRect(); |
| 241 |
|
bool ComputePixel(int x, int y); |
| 242 |
|
bool BelowSampThresh(int x, int y, const int noff[4][2]) const; |
| 243 |
< |
void FillSquare(int x, int y, const int noff[4][2]); |
| 243 |
> |
void FillSquare(const int x, const int y, const int noff[4][2]); |
| 244 |
|
void NewBar(int ht = 0); |
| 245 |
|
bool LowerBar(int v); |
| 246 |
|
bool RenderBelow(int ytop, const int vstep, FILE *pfp, |
| 356 |
|
/// Render and write a frame to the named file |
| 357 |
|
/// Include any header lines set prior to call |
| 358 |
|
/// Picture file must not already exist |
| 359 |
< |
/// Picture to stdout if pfname==NULL |
| 360 |
< |
/// Depth written to a command if dfname[0]=='!' |
| 359 |
> |
/// Write pixels to stdout if !pfname |
| 360 |
> |
/// Write depth to a command if dfname[0]=='!' |
| 361 |
|
RenderDataType RenderFrame(const char *pfname, |
| 362 |
|
RenderDataType dt=RDTrgbe, |
| 363 |
|
const char *dfname=NULL); |