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.1 by greg, Mon Jul 14 18:21:07 2003 UTC vs.
Revision 1.2 by greg, Tue Jul 15 00:23:36 2003 UTC

# Line 60 | Line 60 | normShift16(int i)
60   {
61          int     s = 0;
62          
63 +        if (!i)
64 +                return(-1);
65          while (!(i & 0x8000)) {
66                  i <<= 1;
67                  ++s;
# Line 81 | Line 83 | normShift48(uint16 clr48[3])
83  
84   /* convert at 48-bit tristimulus value to a COLOR */
85   static void
86 < rgb48_color(COLOR col, uint16 clr48[3])
86 > rgb48_color(COLOR col, uint16 clr48[3], double gv)
87   {
88          int     nshft;
89  
90 <        if (cur_gam == 1.) {                    /* linear case */
90 >        if (gv == 1.) {                         /* linear case */
91                  col[0] = clr48[0]*(1./(1L<<16));
92                  col[1] = clr48[1]*(1./(1L<<16));
93                  col[2] = clr48[2]*(1./(1L<<16));
94                  return;
95          }
96                                                  /* non-linear case */
97 +        /* XXX Uncomment if routine is made public
98 +        if (gv != cur_gam)
99 +                mkGamTable(gv);
100 +        */
101          nshft = normShift48(clr48);
102 +        if (nshft < 0) {
103 +                col[0] = col[1] = col[2] = .0f;
104 +                return;
105 +        }
106          col[0] = gamtab[imultpow2(clr48[0],GAMTABBITS-16+nshft)] *
107                          gammul[nshft];
108          col[1] = gamtab[imultpow2(clr48[1],GAMTABBITS-16+nshft)] *
# Line 114 | Line 124 | tmCvGray16(TMbright *ls, uint16 *scan, int len, double
124  
125          if (tmTop == NULL)
126                  returnErr(TM_E_TMINVAL);
127 <        if (ls == NULL | scan == NULL | len < 0 | gv <= MINGAM)
127 >        if (ls == NULL | scan == NULL | len < 0)
128                  returnErr(TM_E_ILLEGAL);
129 +        if (gv <= 0.)
130 +                gv = DEFGAM;
131                                                  /* initialize log table */
132          if (logtab[0] == 0.f)
133                  mkLogTable();
# Line 124 | Line 136 | tmCvGray16(TMbright *ls, uint16 *scan, int len, double
136                                                  /* convert 16-bit grays */
137          while (len--) {
138                  nshft = normShift16(*scan);
139 +                if (nshft < 0) {                /* bogus value */
140 +                        *ls++ = TM_NOBRT;
141 +                        scan++;
142 +                        continue;
143 +                }
144                  d = logtab[ imultpow2(*scan,LOGTABBITS-15+nshft) &
145                                          ((1L<<LOGTABBITS)-1) ]
146                                  - M_LN2*nshft;
# Line 145 | Line 162 | tmCvRGB48(TMbright *ls, BYTE *cs, uint16 (*scan)[3], i
162  
163          if (tmTop == NULL)
164                  returnErr(TM_E_TMINVAL);
165 <        if (ls == NULL | scan == NULL | len < 0 | gv <= MINGAM)
165 >        if (ls == NULL | scan == NULL | len < 0)
166                  returnErr(TM_E_ILLEGAL);
167 +        if (gv <= 0.)
168 +                gv = DEFGAM;
169                                                  /* update gamma table */
170          if (gv != 1. & gv != cur_gam)
171                  mkGamTable(gv);
# Line 160 | Line 179 | tmCvRGB48(TMbright *ls, BYTE *cs, uint16 (*scan)[3], i
179                  if (newscan == NULL)
180                          returnErr(TM_E_NOMEM);
181                  for (i = len; i--; )
182 <                        rgb48_color(newscan[i], scan[i]);
182 >                        rgb48_color(newscan[i], scan[i], gv);
183                  return(tmCvColors(ls, cs, newscan, len));
184          }
185   #if 0

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines