ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/common/tmap16bit.c
(Generate patch)

Comparing ray/src/common/tmap16bit.c (file contents):
Revision 1.6 by greg, Fri Jan 7 21:41:06 2005 UTC vs.
Revision 1.11 by greg, Fri Jan 7 23:01:01 2022 UTC

# Line 21 | Line 21 | static float   logtab[1<<LOGTABBITS];
21   static float    gamtab[1<<GAMTABBITS];
22   static float    gammul[16];
23   static double   cur_gam = 0.;
24 < static BYTE     mongamtab[MONGAMTSZ];
24 > static uby8     mongamtab[MONGAMTSZ];
25   static double   cur_mongam = 0.;
26  
27   #define imultpow2(i,s)  ((s)>=0 ? (i)<<(s) : (i)>>-(s))
# Line 170 | Line 170 | tmCvGray16(TMstruct *tms, TMbright *ls, uint16 *scan,
170  
171   /* Convert a 48-bit RGB scanline to encoded luminance/chrominance */
172   int
173 < tmCvRGB48(TMstruct *tms, TMbright *ls, BYTE *cs,
173 > tmCvRGB48(TMstruct *tms, TMbright *ls, uby8 *cs,
174                  uint16 (*scan)[3], int len, double gv)
175   {
176          static const char       funcName[] = "tmCvRGB48";
# Line 185 | Line 185 | tmCvRGB48(TMstruct *tms, TMbright *ls, BYTE *cs,
185          if (gv <= 0.)
186                  gv = DEFGAM;
187                                                  /* sync input gamma table */
188 <        if ((gv != 1.) & (gv != cur_gam))
188 >        if (gv != cur_gam)
189                  mkGamTable(gv);
190          if (tmNeedMatrix(tms)) {                /* need floating point */
191                  COLOR   *newscan;
# Line 216 | Line 216 | tmCvRGB48(TMstruct *tms, TMbright *ls, BYTE *cs,
216                  if (nshft < 0) {
217                          bi = TM_NOBRT;                  /* bogus value */
218                          lum = 1.;
219 +                        setcolor(cmon, 1., 1., 1.);
220                  } else {
221                          int     j = GAMTABBITS-16+nshft;
222                          int     nshft2;
# Line 234 | Line 235 | tmCvRGB48(TMstruct *tms, TMbright *ls, BYTE *cs,
235                                                  ((1L<<LOGTABBITS)-1) ];
236                          d -= M_LN2*(gv*nshft + nshft2);
237                          d = (double)TM_BRTSCALE*(d + log_inpsf);
238 <                        bi = (int)(d>0. ? d+.5 : d-.5);
238 >                        bi = (int)(d + .5 - (d < 0.));
239                  }
240                                                          /* world luminance */
241                  ls[i] = bi;
# Line 256 | Line 257 | tmCvRGB48(TMstruct *tms, TMbright *ls, BYTE *cs,
257                                  cmon[BLU] = slum + pf*cmon[BLU];
258                          }
259                  } else if (tms->flags & TM_F_BW) {
260 <                        cmon[RED] = cmon[GRN] = cmon[BLU] = lum;
260 >                        int     j = 3;
261 >                        while (j--) cs[3*i+j] = tms->cdiv[j]/(TM_BRES>>8);
262 >                        continue;
263                  }
264                  bi = (double)MONGAMTSZ*tms->clf[RED]*cmon[RED]/lum;
265                  cs[3*i  ] = bi>=MONGAMTSZ ? 255 : mongamtab[bi];

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines