version 1.8 | | version 1.9 |
---|
| | |
/* | | /* |
* static char *rcsid_image_c = | | * static char *rcsid_image_c = |
* "$Id: image.c,v 1.8 2003/06/19 10:59:26 tchize Exp $"; | | * "$Id: image.c,v 1.9 2003/07/08 12:45:04 tchize Exp $"; |
*/ | | */ |
| | |
/* | | /* |
| | |
| | |
struct smoothing { | | struct smoothing { |
uint16 id; | | uint16 id; |
uint16 smooth[8]; | | uint16 smooth; |
}; | | }; |
| | |
static struct smoothing *smooth=NULL; | | static struct smoothing *smooth=NULL; |
| | |
} | | } |
} | | } |
/* Reads the smooth file to know how to smooth datas. | | /* Reads the smooth file to know how to smooth datas. |
* the smooth file if made of 9 elements lines. | | * the smooth file if made of 2 elements lines. |
* lines starting with # are comment | | * lines starting with # are comment |
* the first element of line is face to smooth | | * the first element of line is face to smooth |
* 8 next elements is the 8 faces used for | | * the next element is the 16x2 faces picture |
* smoothing | | * used for smoothing |
*/ | | */ |
int ReadSmooth () { | | int ReadSmooth () { |
char buf[MAX_BUF], *p, *q; | | char buf[MAX_BUF], *p, *q; |
| | |
*p='\0'; | | *p='\0'; |
q=buf; | | q=buf; |
smooth[nrofsmooth].id=FindFace(q,0); | | smooth[nrofsmooth].id=FindFace(q,0); |
for (i=0;i<8;i++){ | | |
q=p+1; | | q=p+1; |
p=strchr(q,' '); | | smooth[nrofsmooth].smooth=FindFace(q,0); |
if ( (!p) && (i<7)) | | |
break; | | |
if (p) | | |
*p='\0'; | | |
smooth[nrofsmooth].smooth[i]=FindFace(q,0); | | |
} | | |
if (i==8) | | |
nrofsmooth++; | | nrofsmooth++; |
} | | } |
fclose(fp); | | fclose(fp); |
| | |
LOG(llevDebug,"done (got %d)\n",nrofsmooth); | | LOG(llevDebug,"done (got %d smooth entries)\n",nrofsmooth); |
qsort (smooth, nrofsmooth, sizeof(struct smoothing), (int (*)())compar_smooth); | | qsort (smooth, nrofsmooth, sizeof(struct smoothing), (int (*)())compar_smooth); |
return nrofsmooth; | | return nrofsmooth; |
} | | } |
| | |
tmp.id = face; | | tmp.id = face; |
bp = (struct smoothing *)bsearch | | bp = (struct smoothing *)bsearch |
(&tmp, smooth, nrofsmooth, sizeof(struct smoothing), (int (*)())compar_smooth); | | (&tmp, smooth, nrofsmooth, sizeof(struct smoothing), (int (*)())compar_smooth); |
for (i=0;i<8;i++){ | | (*smoothed)=0; |
smoothed[i]=0; | | |
} | | |
if (bp) | | if (bp) |
for (i=0;i<8;i++){ | | (*smoothed)=bp->smooth; |
smoothed[i]=bp->smooth[i]; | | |
} | | |
return bp ? 1 : 0; | | return bp ? 1 : 0; |
} | | } |
| | |