1 |
< |
/* Copyright (c) 1992 Regents of the University of California */ |
1 |
> |
/* Copyright (c) 1993 Regents of the University of California */ |
2 |
|
|
3 |
|
#ifndef lint |
4 |
|
static char SCCSid[] = "$SunId$ LBL"; |
32 |
|
/* maximum propagated error during dithering */ |
33 |
|
#define MAXERR 20 |
34 |
|
/* define CLOSEST to get closest colors */ |
35 |
< |
#define CLOSEST 1 |
35 |
> |
#ifndef CLOSEST |
36 |
> |
#ifdef SPEED |
37 |
> |
#if SPEED > 8 |
38 |
> |
#define CLOSEST 1 /* this step takes a little longer */ |
39 |
> |
#endif |
40 |
> |
#endif |
41 |
> |
#endif |
42 |
|
|
43 |
|
|
44 |
|
new_histo() /* clear our histogram */ |
285 |
|
neigh[i][0] = i; /* identity is terminator */ |
286 |
|
} |
287 |
|
/* make neighbor lists */ |
288 |
< |
for (r = 0; r < NRED-1; r++) |
289 |
< |
for (g = 0; g < NGRN-1; g++) |
290 |
< |
for (b = 0; b < NBLU-1; b++) { |
291 |
< |
if (histo[r][g][b] != histo[r+1][g][b]) |
288 |
> |
for (r = 0; r < NRED; r++) |
289 |
> |
for (g = 0; g < NGRN; g++) |
290 |
> |
for (b = 0; b < NBLU; b++) { |
291 |
> |
if (r < NRED-1 && histo[r][g][b] != histo[r+1][g][b]) |
292 |
|
addneigh(neigh, histo[r][g][b], histo[r+1][g][b]); |
293 |
< |
if (histo[r][g][b] != histo[r][g+1][b]) |
293 |
> |
if (g < NGRN-1 && histo[r][g][b] != histo[r][g+1][b]) |
294 |
|
addneigh(neigh, histo[r][g][b], histo[r][g+1][b]); |
295 |
< |
if (histo[r][g][b] != histo[r][g][b+1]) |
295 |
> |
if (b < NBLU-1 && histo[r][g][b] != histo[r][g][b+1]) |
296 |
|
addneigh(neigh, histo[r][g][b], histo[r][g][b+1]); |
297 |
|
} |
298 |
|
/* assign closest values */ |
341 |
|
register BYTE col[3]; |
342 |
|
int r, g, b; |
343 |
|
{ |
344 |
< |
register unsigned tmp; |
344 |
> |
register int tmp; |
345 |
|
register unsigned sum; |
346 |
|
|
347 |
|
tmp = col[RED]*NRED/256 - r; |