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.3 by greg, Tue Oct 3 11:10:10 1989 UTC vs.
Revision 1.4 by greg, Tue Oct 3 14:06:58 1989 UTC

# Line 30 | Line 30 | static char SCCSid[] = "$SunId$ LBL";
30   #define MAXDST2         5
31                                  /* maximum frame buffer depth */
32   #define FBDEPTH         8
33                                /* color map resolution */
34 #define MAPSIZ          256
33                                  /* map a color */
34 < #define map_col(c,p)    clrmap[ colval(c,p)<1. ? \
35 <                                (int)(colval(c,p)*MAPSIZ) : MAPSIZ-1 ]
34 > #define map_col(c,p)    clrmap[p][ colval(c,p)<1. ? \
35 >                                (int)(colval(c,p)*256.) : 255 ]
36                                  /* color partition tree */
37   #define CNODE           short
38   #define set_branch(p,c) ((c)<<2|(p))
# Line 50 | Line 48 | struct tabent {
48          short   ent[3];         /* current table value */
49   }       clrtab[1<<FBDEPTH];
50                                  /* our color correction map */
51 < static BYTE     clrmap[MAPSIZ];
51 > static BYTE     clrmap[3][256];
52                                  /* histogram of colors used */
53   static unsigned histo[NRED][NGRN][NBLU];
54                                  /* initial color cube boundaries */
55   static int      CLRCUBE[3][2] = {0,NRED,0,NGRN,0,NBLU};
56                                  /* color cube partition */
57   static CNODE    ctree[1<<(FBDEPTH+1)];
60                                /* callback for pixel assignment */
61 static int      (*set_pixel)();
58  
59  
60   int
61 < new_ctab(ncolors, cset)         /* start new color table with max ncolors */
61 > new_ctab(ncolors)               /* start new color table with max ncolors */
62   int     ncolors;
67 int     (*cset)();
63   {
64 <        if (ncolors < 1 || ncolors > 1<<FBDEPTH || cset == NULL)
64 >        if (ncolors < 1 || ncolors > 1<<FBDEPTH)
65                  return(0);
71                                /* assign pixel callback routine */
72        set_pixel = cset;
66                                  /* clear color table */
67          bzero(clrtab, sizeof(clrtab));
68                                  /* partition color space */
# Line 82 | Line 75 | int    (*cset)();
75  
76  
77   int
78 < get_pixel(col)                  /* get pixel for color */
78 > get_pixel(col, set_pixel)       /* get pixel for color */
79   COLOR   col;
80 + int     (*set_pixel)();
81   {
82          int     r, g, b;
83          int     cv[3];
# Line 139 | Line 133 | COLOR  col;
133   }
134  
135  
136 < make_cmap(gam)                  /* make gamma correction map */
136 > make_gmap(gam)                  /* make gamma correction map */
137   double  gam;
138   {
139          extern double   pow();
140          register int    i;
141          
142 <        for (i = 0; i < MAPSIZ; i++)
143 <                clrmap[i] = 256.0 * pow(i/(double)MAPSIZ, 1.0/gam);
142 >        for (i = 0; i < 256; i++)
143 >                clrmap[RED][i] =
144 >                clrmap[GRN][i] =
145 >                clrmap[BLU][i] = 256.0 * pow(i/256.0, 1.0/gam);
146 > }
147 >
148 >
149 > set_cmap(rmap, gmap, bmap)      /* set custom color correction map */
150 > BYTE    *rmap, *gmap, *bmap;
151 > {
152 >        bcopy(rmap, clrmap[RED], 256);
153 >        bcopy(gmap, clrmap[GRN], 256);
154 >        bcopy(bmap, clrmap[BLU], 256);
155   }
156  
157  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines