#include #include #include int main(void) { /* Define the file pointer and variable types */ FILE *ifp,*ifo,*ifpc,*ifoc; int nc,nr,nrows,ncolumns; signed short *ptr; signed short i,j; char *wptr, out; nrows=896; ncolumns=896; /* Open the file read only binary */ ifp = fopen("c5decA92", "rb"); ifo = fopen("c5decA92.bin", "wb"); ifpc = fopen("c5decC92", "rb"); ifoc = fopen("c5decC92.bin", "wb"); /* Apparently the file has an initial offset of one */ fseek(ifp,+1, SEEK_CUR); fseek(ifpc,+1, SEEK_CUR); /* Begin the loops that will cover the rows and columns of the data file.... */ for (nc=1; nc <= ncolumns;++nc){ for (nr=1; nr <= nrows;++nr){ ptr=&i; wptr=&out; fread(ptr, 2, 1, ifp); if (i <= 513 ) out=1; if (i <= 1 ) out=255; if (i > 513) out=((i-512)/2); fwrite(wptr, 1, 1, ifo); ptr=&i; wptr=&out; fread(ptr, 2, 1, ifpc); if (i <= 513 ) out=1; if (i <= 1 ) out=255; if (i > 513) out=((i-512)/2); fwrite(wptr, 1, 1, ifoc); /* The for loops end here */ }} close(ifp); close(ifo); close(ifpc); close(ifoc); exit(0); }