1 |
– |
/* Copyright 1988 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 |
|
CIQ - main program for color image quantization |
6 |
|
options for Floyd-Steinberg dithering by minimization of accumulated error |
10 |
|
Greg Ward 1 March 88, modified for arbitrary picture sizes |
11 |
|
*/ |
12 |
|
|
13 |
+ |
#include "standard.h" |
14 |
|
#include "ciq.h" |
15 |
|
|
16 |
|
#define table(m,r,g,b) hist[m[0][r]|m[1][g]|m[2][b]] /* histogram/pvtable */ |
41 |
|
if (synth) |
42 |
|
n = makecm(nw,&na); /* analyze histogram and synthesize colormap */ |
43 |
|
else { |
44 |
< |
bcopy(cm,color,sizeof color); |
44 |
> |
bcopy((char *)cm,(char *)color,sizeof color); |
45 |
|
n = nw; |
46 |
|
na = 0; |
47 |
|
for (i=0; i<len; i++) if (hist[i]) na++; |
58 |
|
draw_nodith(ocm); |
59 |
|
} |
60 |
|
|
61 |
< |
bcopy(color,cm,sizeof color); |
61 |
> |
bcopy((char *)color,(char *)cm,sizeof color); |
62 |
|
/*endclosest();*/ |
63 |
|
} |
64 |
|
|
83 |
|
for (lp=line, x=0; x<xmax; x++, lp++) |
84 |
|
table(map,lp->r,lp->g,lp->b)++; |
85 |
|
} |
86 |
< |
free((char *)line); |
86 |
> |
free((void *)line); |
87 |
|
} |
88 |
|
|
89 |
|
convertmap(in,out) /* convert to shifted color map */ |
117 |
|
oline[x] = table(map,lp->r,lp->g,lp->b); |
118 |
|
picwriteline(y,oline); |
119 |
|
} |
120 |
< |
free((char *)iline); |
121 |
< |
free((char *)oline); |
120 |
> |
free((void *)iline); |
121 |
> |
free((void *)oline); |
122 |
|
} |
123 |
|
|
124 |
|
draw_dith(ocm) /* quantize with dithering */ |
167 |
|
} |
168 |
|
picwriteline(y,oline); |
169 |
|
} |
170 |
< |
free((char *)iline); |
171 |
< |
free((char *)oline); |
172 |
< |
free((char *)buf); |
170 |
> |
free((void *)iline); |
171 |
> |
free((void *)oline); |
172 |
> |
free((void *)buf); |
173 |
|
} |