/* clip.c cl1.bat = cl /AL clip.c Reads an 8 bit image and (1) clips and/or samples it as is, (2) rescales a b&w image from 0 - 63 and makes a color table from 64 - 255 with 6 reds, 8 greens and 4 blues clip [infile] [irw] [icl] [outfile] [rw1] [cl1] [orw] [ocl] [sample] [/iop] where: infile --- input file name with extension irws ----- number of rows in input image icls ----- number of columns in input image outfile -- output file name without extension rw1 ------ first row in input image to use in output image cl1 ------ first column in input image to use in output image orws ----- number of rows in output image ocls ----- number of columns in output image iop ------ /1 for clip and sample: /2 for grey scale compression to 64 and color above */ #include #include #define NUMRED 6 #define NUMGRN 6 #define NUMBLU 5 #define MAXPTS 25000 #define PAUSE printf("HIT ANY KEY TO CONTINUE.\n");getch() unsigned char Buffer[MAXPTS]; int Red[NUMRED]={0,51,102,153,204,255}; int Grn[NUMGRN]={0,51,102,153,204,255}; int Blu[NUMBLU]={0,64,128,191,255}; main(int argc,char *argv[]) { long i,j,k,l,m,n,r,g,b; long irow,icol,orow,ocol,row1,col1; char infile[100],outname[100],string[100],cr=0xd; FILE *fpin,*fplbl,*fppal,*fpdat,*fppal2; long offset,sample=1; char iop; if(argc<10) { printf("Not enough parameters\n"); print_format(); } strcpy(infile,argv[1]); fpin=fopen(infile,"rb"); if(!fpin) not_open(infile,"read"); if(sscanf(argv[2],"%ld",&irow)<1) not_read("irow"); if(sscanf(argv[3],"%ld",&icol)<1) not_read("icol"); if(sscanf(argv[5],"%ld",&row1)<1) not_read("row1"); if(sscanf(argv[6],"%ld",&col1)<1) not_read("col1"); if(sscanf(argv[7],"%ld",&orow)<1) not_read("orow"); if(sscanf(argv[8],"%ld",&ocol)<1) not_read("ocol"); if(sscanf(argv[9],"%ld",&sample)<1) not_read("sample"); if(argv[10][0]!='/') not_read("/iop"); iop=argv[10][1]; if(iop!='1'&&iop!='2') not_read("/iop"); strcpy(outname,argv[4]); sprintf(string,"%s.lbl",outname); fplbl=fopen(string,"wt"); if(!fplbl) not_open(string,"write"); if(iop=='1') { strcpy(string,infile); for(k=0;k