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

Comparing ray/src/common/colrops.c (file contents):
Revision 1.1 by greg, Fri Oct 19 16:33:44 1990 UTC vs.
Revision 2.2 by greg, Tue Feb 18 15:25:55 1992 UTC

# Line 10 | Line 10 | static char SCCSid[] = "$SunId$ LBL";
10  
11   #include "color.h"
12  
13 < #define MAXGSHIFT       2               /* maximum shift for gamma table */
13 > #define MAXGSHIFT       15              /* maximum shift for gamma table */
14  
15   static BYTE     g_mant[256], g_nexp[256];
16  
# Line 32 | Line 32 | double g;
32                                          /* compute gamb -> colr mapping */
33          i = 0;
34          mult = 256.0;
35 <        for (j = 255; j >= 0; j--) {
36 <        rept:
37 <                g_mant[j] = mult * pow((j+.5)/256.0, g);
38 <                if (g_mant[j] < 128) {
35 >        for (j = 255; j > 0; j--) {
36 >                while ((g_mant[j] = mult * pow(j/256.0, g)) < 128) {
37                          i++;
38                          mult *= 2.0;
41                        goto rept;
39                  }
40                  g_nexp[j] = i;
41          }
42 +        g_mant[0] = 0;
43 +        g_nexp[0] = COLXS;
44   }
45  
46  
# Line 129 | Line 128 | register COLR  *scan;
128   register int    len;
129   register int    adjust;
130   {
131 +        int     minexp;
132 +
133 +        if (adjust == 0)
134 +                return;
135 +        minexp = adjust < 0 ? -adjust : 0;
136          while (len-- > 0) {
137 <                scan[0][EXP] += adjust;
137 >                if (scan[0][EXP] <= minexp)
138 >                        scan[0][RED] = scan[0][GRN] = scan[0][BLU] =
139 >                        scan[0][EXP] = 0;
140 >                else
141 >                        scan[0][EXP] += adjust;
142                  scan++;
143          }
144   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines