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 2.3 by greg, Mon Mar 8 12:37:21 1993 UTC vs.
Revision 2.9 by schorsch, Tue Mar 30 16:13:01 2004 UTC

# Line 1 | Line 1
1 /* Copyright (c) 1992 Regents of the University of California */
2
1   #ifndef lint
2 < static char SCCSid[] = "$SunId$ LBL";
2 > static const char       RCSid[] = "$Id$";
3   #endif
6
4   /*
5   * colortab.c - allocate and control dynamic color table.
6   *
# Line 14 | Line 11 | static char SCCSid[] = "$SunId$ LBL";
11   *      histogram is cleared.  This algorithm
12   *      performs only as well as the next drawing's color
13   *      distribution is correlated to the last.
14 + *
15 + *  External symbols declared in drvier.h
16   */
17  
18 < #include "standard.h"
18 > #include "copyright.h"
19  
20 + #include <string.h>
21 +
22 + #include "standard.h"
23   #include "color.h"
24 + #include "driver.h"
25 +
26                                  /* histogram resolution */
27   #define NRED            24
28   #define NGRN            32
# Line 55 | Line 59 | static unsigned short  histo[NRED][NGRN][NBLU];
59                                  /* initial color cube boundary */
60   static int      CLRCUBE[3][2] = {{0,NRED},{0,NGRN},{0,NBLU}};
61  
62 < static int      split(), cut();
62 > static int      split();
63 > static void     cut();
64  
65  
66   int
# Line 68 | Line 73 | int    ncolors;
73                  return(0);
74                                  /* free old tables */
75          if (clrtab != NULL)
76 <                free((char *)clrtab);
76 >                free((void *)clrtab);
77          if (ctree != NULL)
78 <                free((char *)ctree);
78 >                free((void *)ctree);
79                                  /* get new tables */
80          for (treesize = 1; treesize < ncolors; treesize <<= 1)
81                  ;
# Line 82 | Line 87 | int    ncolors;
87                                  /* partition color space */
88          cut(ctree, 0, CLRCUBE, 0, ncolors);
89                                  /* clear histogram */
90 <        bzero((char *)histo, sizeof(histo));
90 >        memset((void *)histo, '\0', sizeof(histo));
91                                  /* return number of colors used */
92          return(ncolors);
93   }
94  
95  
96 < int
97 < get_pixel(col, set_pixel)       /* get pixel for color */
98 < COLOR   col;
99 < int     (*set_pixel)();
96 > extern int
97 > get_pixel(      /* get pixel for color */
98 >        COLOR   col,
99 >        dr_newcolrf_t *newcolr
100 > )
101   {
96        extern char     errmsg[];
102          int     r, g, b;
103          int     cv[3];
104          register CNODE  *tp;
# Line 137 | Line 142 | int    (*set_pixel)();
142                                  h, r, g, b, clrtab[h].n);
143                  eputs(errmsg);
144   #endif
145 <                (*set_pixel)(h, r, g, b);
145 >                (*newcolr)(h, r, g, b);
146          }
147          return(h);                              /* return pixel value */
148   }
149  
150  
151 + void
152   make_gmap(gam)                  /* make gamma correction map */
153   double  gam;
154   {
# Line 155 | Line 161 | double gam;
161   }
162  
163  
164 + void
165   set_cmap(rmap, gmap, bmap)      /* set custom color correction map */
166   BYTE    *rmap, *gmap, *bmap;
167   {
168 <        bcopy((char *)rmap, (char *)clrmap[RED], 256);
169 <        bcopy((char *)gmap, (char *)clrmap[GRN], 256);
170 <        bcopy((char *)bmap, (char *)clrmap[BLU], 256);
168 >        memcpy((void *)clrmap[RED], (void *)rmap, 256);
169 >        memcpy((void *)clrmap[GRN], (void *)gmap, 256);
170 >        memcpy((void *)clrmap[BLU], (void *)bmap, 256);
171   }
172  
173  
174 + void
175   map_color(rgb, col)             /* map a color to a byte triplet */
176   BYTE    rgb[3];
177   COLOR   col;
# Line 174 | Line 182 | COLOR  col;
182   }
183  
184  
185 < static
185 > static void
186   cut(tree, level, box, c0, c1)           /* partition color space */
187   register CNODE  *tree;
188   int     level;
# Line 189 | Line 197 | int    c0, c1;
197          }
198                                          /* split box */
199          *tree = split(box);
200 <        bcopy((char *)box, (char *)kb, sizeof(kb));
200 >        memcpy((void *)kb, (void *)box, sizeof(kb));
201                                                  /* do left (lesser) branch */
202          kb[prim(*tree)][1] = part(*tree);
203          cut(tree+(1<<level), level+1, kb, c0, (c0+c1)>>1);
# Line 207 | Line 215 | register int   box[3][2];
215   #define c0      r
216          register int    r, g, b;
217          int     pri;
218 <        int     t[HMAX], med;
218 >        long    t[HMAX], med;
219                                          /* find dominant axis */
220          pri = RED;
221          if (box[GRN][1]-box[GRN][0] > box[pri][1]-box[pri][0])

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines