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

Comparing ray/src/rt/colortab.c (file contents):
Revision 1.10 by greg, Tue Jan 16 16:00:00 1990 UTC vs.
Revision 1.15 by greg, Wed Nov 7 17:16:58 1990 UTC

# Line 16 | Line 16 | static char SCCSid[] = "$SunId$ LBL";
16   *      distribution is correlated to the last.
17   */
18  
19 < #include "color.h"
19 > #include "standard.h"
20  
21 < #define NULL            0
21 > #include "color.h"
22                                  /* histogram resolution */
23   #define NRED            24
24   #define NGRN            32
# Line 43 | Line 43 | static char SCCSid[] = "$SunId$ LBL";
43                                  /* our color table */
44   static struct tabent {
45          long    sum[3];         /* sum of colors using this entry */
46 <        long    n;              /* number of colors */
47 <        short   ent[3];         /* current table value */
46 >        int     n;              /* number of colors */
47 >        BYTE    ent[3];         /* current table value */
48   }       *clrtab = NULL;
49                                  /* color cube partition */
50   static CNODE    *ctree = NULL;
# Line 80 | Line 80 | int    ncolors;
80                                  /* partition color space */
81          cut(ctree, 0, CLRCUBE, 0, ncolors);
82                                  /* clear histogram */
83 <        bzero(histo, sizeof(histo));
83 >        bzero((char *)histo, sizeof(histo));
84                                  /* return number of colors used */
85          return(ncolors);
86   }
# Line 91 | Line 91 | get_pixel(col, set_pixel)      /* get pixel for color */
91   COLOR   col;
92   int     (*set_pixel)();
93   {
94 +        extern char     errmsg[];
95          int     r, g, b;
96          int     cv[3];
97          register CNODE  *tp;
# Line 110 | Line 111 | int    (*set_pixel)();
111                  if (cv[prim(*tp)] < part(*tp))
112                          tp += 1<<h;             /* left branch */
113                  else
114 <                        tp += 1<<(h+1); /* right branch */
114 >                        tp += 1<<(h+1);         /* right branch */
115          h = pval(*tp);
116                                                  /* add to color table */
117          clrtab[h].sum[RED] += r;
# Line 129 | Line 130 | int    (*set_pixel)();
130                  clrtab[h].ent[RED] = r;
131                  clrtab[h].ent[GRN] = g; /* reassign pixel */
132                  clrtab[h].ent[BLU] = b;
133 < #ifdef notdef
134 <                printf("pixel %d = (%d,%d,%d) (%d refs)\n",
133 > #ifdef DEBUG
134 >                sprintf(errmsg, "pixel %d = (%d,%d,%d) (%d refs)\n",
135                                  h, r, g, b, clrtab[h].n);
136 +                eputs(errmsg);
137   #endif
138                  (*set_pixel)(h, r, g, b);
139          }
# Line 148 | Line 150 | double  gam;
150          for (i = 0; i < 256; i++)
151                  clrmap[RED][i] =
152                  clrmap[GRN][i] =
153 <                clrmap[BLU][i] = 256.0 * pow(i/256.0, 1.0/gam);
153 >                clrmap[BLU][i] = 256.0 * pow((i+0.5)/256.0, 1.0/gam);
154   }
155  
156  
157   set_cmap(rmap, gmap, bmap)      /* set custom color correction map */
158   BYTE    *rmap, *gmap, *bmap;
159   {
160 <        bcopy(rmap, clrmap[RED], 256);
161 <        bcopy(gmap, clrmap[GRN], 256);
162 <        bcopy(bmap, clrmap[BLU], 256);
160 >        bcopy((char *)rmap, (char *)clrmap[RED], 256);
161 >        bcopy((char *)gmap, (char *)clrmap[GRN], 256);
162 >        bcopy((char *)bmap, (char *)clrmap[BLU], 256);
163   }
164  
165  
166 + map_color(rgb, col)             /* map a color to a byte triplet */
167 + BYTE    rgb[3];
168 + COLOR   col;
169 + {
170 +        rgb[RED] = map_col(col,RED);
171 +        rgb[GRN] = map_col(col,GRN);
172 +        rgb[BLU] = map_col(col,BLU);
173 + }
174 +
175 +
176   static
177   cut(tree, level, box, c0, c1)           /* partition color space */
178   register CNODE  *tree;
# Line 176 | Line 188 | int    c0, c1;
188          }
189                                          /* split box */
190          *tree = split(box);
191 <        bcopy(box, kb, sizeof(kb));
191 >        bcopy((char *)box, (char *)kb, sizeof(kb));
192                                                  /* do left (lesser) branch */
193          kb[prim(*tree)][1] = part(*tree);
194          cut(tree+(1<<level), level+1, kb, c0, (c0+c1)>>1);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines