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 <string.h> |
14 |
+ |
|
15 |
+ |
#include "standard.h" |
16 |
|
#include "ciq.h" |
17 |
|
|
18 |
|
#define table(m,r,g,b) hist[m[0][r]|m[1][g]|m[2][b]] /* histogram/pvtable */ |
43 |
|
if (synth) |
44 |
|
n = makecm(nw,&na); /* analyze histogram and synthesize colormap */ |
45 |
|
else { |
46 |
< |
bcopy(cm,color,sizeof color); |
46 |
> |
memcpy((void *)color,(void *)cm,sizeof color); |
47 |
|
n = nw; |
48 |
|
na = 0; |
49 |
|
for (i=0; i<len; i++) if (hist[i]) na++; |
60 |
|
draw_nodith(ocm); |
61 |
|
} |
62 |
|
|
63 |
< |
bcopy(color,cm,sizeof color); |
63 |
> |
memcpy((void *)cm,(void *)color,sizeof color); |
64 |
|
/*endclosest();*/ |
65 |
|
} |
66 |
|
|
85 |
|
for (lp=line, x=0; x<xmax; x++, lp++) |
86 |
|
table(map,lp->r,lp->g,lp->b)++; |
87 |
|
} |
88 |
< |
free((char *)line); |
88 |
> |
free((void *)line); |
89 |
|
} |
90 |
|
|
91 |
|
convertmap(in,out) /* convert to shifted color map */ |
119 |
|
oline[x] = table(map,lp->r,lp->g,lp->b); |
120 |
|
picwriteline(y,oline); |
121 |
|
} |
122 |
< |
free((char *)iline); |
123 |
< |
free((char *)oline); |
122 |
> |
free((void *)iline); |
123 |
> |
free((void *)oline); |
124 |
|
} |
125 |
|
|
126 |
|
draw_dith(ocm) /* quantize with dithering */ |
169 |
|
} |
170 |
|
picwriteline(y,oline); |
171 |
|
} |
172 |
< |
free((char *)iline); |
173 |
< |
free((char *)oline); |
174 |
< |
free((char *)buf); |
172 |
> |
free((void *)iline); |
173 |
> |
free((void *)oline); |
174 |
> |
free((void *)buf); |
175 |
|
} |