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 |
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; |
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; |
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; |
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 |
|
|
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 |
|
|