/* view5d.c v51.bat = cl /AL view5d.c vimage3 graphlib */ #include #include #include #include "font.h" #include "nomouse.h" #define MAX_BUFF 32768 #define MAXSIZE 16384 #define RED 240 #define ORANGE 241 #define YELLOW 242 #define GREEN 243 #define CYAN 244 #define BLUE 245 #define PURPLE 246 #define MAGENTA 247 #define BROWN 248 #define D_BLUE 249 #define D_CYAN 250 #define BLACK 251 #define D_GREY 252 #define M_GREY 253 #define L_GREY 254 #define WHITE 255 #define MENUXC 550 #define MENU_V 4 char *Menu_V[MENU_V]= { "cursor on image", "rectangle image", "slice RGB scatter", "exit image view" }; struct Color { unsigned char r, g, b; }Lut[256]; struct Color Vcolor[16]= { { 255, 0, 0}, { 255,128, 0}, { 191,191, 0}, { 0,255, 0}, { 0,191,191}, { 40, 40,255}, { 128, 0,255}, { 191, 0,191}, { 96, 28, 14}, { 0, 20, 60}, { 0,128,128}, { 0, 0, 0}, { 46, 46, 46}, { 128,128,128}, { 191,191,191}, { 255,255,255} }; char SubType[20],VideoType='X'; struct board { int row,col,color; }B_Id; int FontSize=2; int ScreenXs=640,ScreenYs=480; unsigned char Buffer[3][MAXSIZE],Outbuff[MAXSIZE][3],Mbuff[MAX_BUFF]; unsigned char BoxBuff[3][8][256]; int Cr=0xd; struct image_header { int row,col,sample; /* source color image */ int imgrow,imgcol; /* sub image '.?5d' */ char infile[3][100]; int negative[3]; int imgmax[3],imgmin[3]; int dummy[92]; struct Color lut[256]; }Hdr; int Source_Row,Source_Col; int Range[3]; char Palette[100],Image[100]; unsigned char getpt(); char fsplit(char *,char *,char *,char *); main(argc,argv) int argc; char *argv[]; { int i,j,k; char string[100],lblname[100],ans,name_5d[100]; int numfile; FILE *fp; if(argc>1) { for(i=1;i to mark",FontSize,Font); plot_font_h(L_GREY,ScreenXs/2+2,bysize+2+high*3, " to exit",FontSize,Font); plot_font_h(L_GREY,ScreenXs/2+2,bysize+2+high*4, "(l)arger,(s)maller",FontSize,Font); plot_font_h(L_GREY,ScreenXs/2+2,bysize+2+high*5, "(N)arrower,(W)ider",FontSize,Font); plot_font_h(L_GREY,ScreenXs/2+2,bysize+2+high*6, "(S)horter,(H)igher",FontSize,Font); offsethdr=(long)sizeof(struct image_header); offsethdr+=(long)Hdr.imgrow*(long)Hdr.imgcol; ix=ixo=Hdr.imgcol/2-bxsize/2; iy=iyo=Hdr.imgrow/2-bysize/2; if(iy<0)iy=0; if(ix<0)ix=0; tbox_val(0,ix,iy,bxsize,bysize,Mbuff,dark,WHITE,180); offset=lcol*(long)iy+(long)ix; do { if(plot==0) ans=getch(); plot=0; if(ans==0) { ans2=getch(); if(ans2==82) dark+=1; if(ans2==83) dark-=1; if(dark<240) dark=255; if(dark>255) dark=240; if(ans2==71||ans2==72||ans2==73) iy-=speed; if(ans2==79||ans2==80||ans2==81) iy+=speed; if(ans2==71||ans2==75||ans2==79) ix-=speed; if(ans2==73||ans2==77||ans2==81) ix+=speed; if(ix<0) ix=0; if(iy<0) iy=0; if(ix>=Hdr.imgcol) ix=Hdr.imgcol-1; if(iy>=Hdr.imgrow) iy=Hdr.imgrow-1; if(ix+bxsize>Hdr.imgcol) ix=Hdr.imgcol-bxsize; if(iy+bysize>Hdr.imgrow) iy=Hdr.imgrow-bysize; unbox(0,ixo,iyo,bxsizeo,bysizeo,Mbuff); tbox_val(0,ix,iy,bxsize,bysize,Mbuff,dark,WHITE,180); ixo=ix; iyo=iy; } if(ans=='l'||ans=='s'||ans=='H'||ans=='W'||ans=='N'||ans=='S') { if(ans=='l'||ans=='W') bxsize+=speed; if(ans=='l'||ans=='H') bysize+=speed; if(ans=='s'||ans=='N') bxsize-=speed; if(ans=='s'||ans=='S') bysize-=speed; if(bxsize<4) bxsize=4; if(bysize<4) bysize=4; if(bxsize>Hdr.imgcol) bxsize=Hdr.imgcol; if(bysize>Hdr.imgrow) bysize=Hdr.imgrow; if(ix+bxsize>Hdr.imgcol) ix=Hdr.imgcol-bxsize; if(iy+bysize>Hdr.imgrow) iy=Hdr.imgrow-bysize; if(ix<0) ix=0; if(iy<0) iy=0; unbox(0,ixo,iyo,bxsizeo,bysizeo,Mbuff); tbox_val(0,ix,iy,bxsize,bysize,Mbuff,dark,WHITE,180); bxsizeo=bxsize; bysizeo=bysize; ixo=ix; iyo=iy; } if(ans=='+'&&speed<32) speed*=2; if(ans=='-'&&speed>1) speed/=2; if(ans==13) /* mark points */ { for(i=iy;i255) markcolor=RED; } if(ans=='C') { markcolor-=1; if(markcolorxc[k]&&x[k]yc[k]&&y[k]xc[k]+10&&x[k]yc[k]+10&&y[k]0) { val=getch(); if(val==27) { video_off(); return(-2); } } val=getpt(0,j,i); set_xy(x,y,xaxis,yaxis,xc,yc,Outbuff[j],scale,size); for(k=0;k<3;k++) plotpt(0,x[k],y[k],val); } } fseek(fp,(long)0,SEEK_END); for(k=0;k<3;k++) { for(i=0;i=0) { fp=fopen(string,"rb"); if(!fp) { printf("Could not open '%s' to read.\n",string); exit(0); } fread((char *)&Hdr,sizeof(struct image_header),1,fp); for(k=0;k<3;k++) { Range[k]=Hdr.imgmax[k]-Hdr.imgmin[k]; if(Range[k] to mark",FontSize,Font); plot_font_h(L_GREY,ScreenXs/2+2,bysize+2+high*6, " to exit",FontSize,Font); offsethdr=(long)sizeof(struct image_header); offsethdr+=(long)Hdr.imgrow*(long)Hdr.imgcol; offset=sizeof(struct image_header); for(k=0;k<3;k++) { sprintf(number,"%d",k+1); if(k==active) plot_font_h(WHITE,xc[k]+2,ScreenYs/2+2,number,FontSize,Font); else plot_font_h(M_GREY,xc[k]+2,ScreenYs/2+2,number,FontSize,Font); } set_boxes(datmax,datmin,dathi,datlo,xaxis,yaxis,xc,yc,scale,size); for(m=0;m<3;m++) { dathio[m]=dathi[m]; datloo[m]=datlo[m]; } tplot_boxes(datmax,datmin,dathi,datlo,xaxis,yaxis,xc,yc,scale,size); do { ans=getch(); if(ans=='i') direction=-1; if(ans=='o') direction=1; if(ans==0) { ans2=getch(); if(ans2==72) { dathi[yaxis[active]]+=speed*direction; if(dathi[yaxis[active]]datmax[yaxis[active]]) dathi[yaxis[active]]=datmax[yaxis[active]]; } if(ans2==80) { datlo[yaxis[active]]-=speed*direction; if(datlo[yaxis[active]]>dathi[yaxis[active]]) datlo[yaxis[active]]=dathi[yaxis[active]]; if(datlo[yaxis[active]]datmax[xaxis[active]]) dathi[xaxis[active]]=datmax[xaxis[active]]; } if(ans2==75) { datlo[xaxis[active]]-=speed*direction; if(datlo[xaxis[active]]>dathi[xaxis[active]]) datlo[xaxis[active]]=dathi[xaxis[active]]; if(datlo[xaxis[active]]dathi[m]) { hit=0; break; } } if(hit==1) plotpt(0,j,i,mark); } } while((ans=getch())=='c'||ans=='C'||ans=='f') { if(ans=='f') { if(markcolor==WHITE) markcolor=BLACK; else markcolor=WHITE; } if(ans=='c') { markcolor+=1; if(markcolor>255) markcolor=RED; } if(ans=='C') { markcolor-=1; if(markcolor1) speed/=2; if(ans=='c') { markcolor+=1; if(markcolor>255) markcolor=RED; WritePaletteIndex(&Hdr.lut[markcolor],mark); } if(ans=='C') { markcolor-=1; if(markcolor='1'&&ans<='3') { active=ans-'1'; for(k=0;k<3;k++) { sprintf(number,"%d",k+1); if(k==active) plot_font_h(WHITE,xc[k]+2,ScreenYs/2+2,number,FontSize,Font); else plot_font_h(M_GREY,xc[k]+2,ScreenYs/2+2,number,FontSize,Font); } } if(ans==0||ans=='r') { paint_box(0,D_GREY,Outbuff,0,ScreenYs/2,110/FontSize,90/FontSize); sprintf(number,"%3d %3d",datlo[0],dathi[0]); plot_font_h(RED,2,ScreenYs/2+2,number,FontSize,Font); sprintf(number,"%3d %3d",datlo[1],dathi[1]); plot_font_h(GREEN,2,ScreenYs/2+2+30/FontSize,number,FontSize,Font); sprintf(number,"%3d %3d",datlo[2],dathi[2]); plot_font_h(BLUE,2,ScreenYs/2+2+60/FontSize,number,FontSize,Font); } }while(ans!=27); for(k=0;k<3;k++) { sprintf(number,"%d",k+1); if(k==active) plot_font_h(L_GREY,xc[k]+2,ScreenYs/2+2,number,FontSize,Font); } paint_box(0,D_GREY,Outbuff,ScreenXs/2,0,ScreenXs/2,ScreenYs/2); unplot_boxes(datmax,datmin,dathio,datloo,xaxis,yaxis,xc,yc,scale,size); for(k=0;k<3;k++) { sprintf(number,"%d",k+1); plot_font_h(L_GREY,xc[k]+2,ScreenYs/2+2,number,FontSize,Font); } paint_box(0,D_GREY,Outbuff,0,ScreenYs/2,110/FontSize,90/FontSize); } /*********************************************************************** ** ** ** ** ************************************************************************/ int tplot_boxes(datmax,datmin,dathi,datlo,xaxis,yaxis,xc,yc,scale,size) int *datmax,*datmin,*dathi,*datlo,*xaxis,*yaxis,*xc,*yc,scale,size; { int i,j,k,m,n; int x[3],y[3],px[3][9],py[3][9],val=WHITE; unsigned char point[3]; for(k=0;k<3;k++) point[k]=0; for(m=0;m<3;m++) { point[yaxis[m]]=dathi[yaxis[m]]; point[xaxis[m]]=datlo[xaxis[m]]; set_xy(x,y,xaxis,yaxis,xc,yc,point,scale,size); px[m][0]=px[m][7]=px[m][8]=x[m]; py[m][0]=py[m][7]=py[m][8]=y[m]; point[yaxis[m]]=dathi[yaxis[m]]; point[xaxis[m]]=dathi[xaxis[m]]; set_xy(x,y,xaxis,yaxis,xc,yc,point,scale,size); px[m][1]=px[m][2]=x[m]; py[m][1]=py[m][2]=y[m]; point[yaxis[m]]=datlo[yaxis[m]]; point[xaxis[m]]=dathi[xaxis[m]]; set_xy(x,y,xaxis,yaxis,xc,yc,point,scale,size); px[m][3]=px[m][4]=x[m]; py[m][3]=py[m][4]=y[m]; point[yaxis[m]]=datlo[yaxis[m]]; point[xaxis[m]]=datlo[xaxis[m]]; set_xy(x,y,xaxis,yaxis,xc,yc,point,scale,size); px[m][5]=px[m][6]=x[m]; py[m][5]=py[m][6]=y[m]; } for(m=0;m<3;m++) { for(i=0;i<8;i++) { if(px[m][i]!=px[m][i+1]||py[m][i]!=py[m][i+1]) { tplotln_val(0,px[m][i],py[m][i],px[m][i+1],py[m][i+1], BoxBuff[m][i],val); } } } } /*********************************************************************** ** ** ** ** ************************************************************************/ int unplot_boxes(datmax,datmin,dathi,datlo,xaxis,yaxis,xc,yc,scale,size) int *datmax,*datmin,*dathi,*datlo,*xaxis,*yaxis,*xc,*yc,scale,size; { int i,j,k,m,n; int x[3],y[3],px[3][9],py[3][9],val=WHITE; unsigned char point[3]; for(k=0;k<3;k++) point[k]=0; for(m=0;m<3;m++) { point[yaxis[m]]=dathi[yaxis[m]]; point[xaxis[m]]=datlo[xaxis[m]]; set_xy(x,y,xaxis,yaxis,xc,yc,point,scale,size); px[m][0]=px[m][7]=px[m][8]=x[m]; py[m][0]=py[m][7]=py[m][8]=y[m]; point[yaxis[m]]=dathi[yaxis[m]]; point[xaxis[m]]=dathi[xaxis[m]]; set_xy(x,y,xaxis,yaxis,xc,yc,point,scale,size); px[m][1]=px[m][2]=x[m]; py[m][1]=py[m][2]=y[m]; point[yaxis[m]]=datlo[yaxis[m]]; point[xaxis[m]]=dathi[xaxis[m]]; set_xy(x,y,xaxis,yaxis,xc,yc,point,scale,size); px[m][3]=px[m][4]=x[m]; py[m][3]=py[m][4]=y[m]; point[yaxis[m]]=datlo[yaxis[m]]; point[xaxis[m]]=datlo[xaxis[m]]; set_xy(x,y,xaxis,yaxis,xc,yc,point,scale,size); px[m][5]=px[m][6]=x[m]; py[m][5]=py[m][6]=y[m]; } for(m=0;m<3;m++) { for(i=7;i>=0;i--) { if(px[m][i]!=px[m][i+1]||py[m][i]!=py[m][i+1]) { unplotln(0,px[m][i],py[m][i],px[m][i+1],py[m][i+1], BoxBuff[m][i],val); } } } } /*********************************************************************** ** ** ** ** ************************************************************************/ int set_boxes(datmax,datmin,dathi,datlo,xaxis,yaxis,xc,yc,scale,size) int *datmax,*datmin,*dathi,*datlo,*xaxis,*yaxis,*xc,*yc,scale,size; { int i,j,k; for(k=0;k<3;k++) { Range[k]=Hdr.imgmax[k]-Hdr.imgmin[k]; if(Range[k]len)len=l; if(len==0)return(-1); wide=(len+1)*15/size+1; if((ScreenXs-1-wide)0)val-=1; else val=num-1; } if(ans2=='P') { if(val255) dark=240; if(ans==71||ans==72||ans==73) iy-=speed; if(ans==79||ans==80||ans==81) iy+=speed; if(ans==71||ans==75||ans==79) ix-=speed; if(ans==73||ans==77||ans==81) ix+=speed; if(ix<0) ix=0; if(iy<0) iy=0; if(ix>=Hdr.imgcol) ix=Hdr.imgcol-1; if(iy>=Hdr.imgrow) iy=Hdr.imgrow-1; uncursor(0,ixo,iyo,csize,cbuff); tcursor_val(0,ix,iy,csize,cbuff,dark,WHITE,180); for(k=0;k<3;k++) uncursor(0,pxo[k],pyo[k],csize,pbuff[k]); offset=lcol*(long)iy+(long)ix; fseek(fp,offsethdr+offset*3,SEEK_SET); fread((char *)point,sizeof(char),3,fp); paint_box(0,D_GREY,Outbuff,ScreenXs/2,0,22*wide,5*high+5); sprintf(string,"SCREEN"); plot_font_h(WHITE,ScreenXs/2+4,2,string,FontSize,Font); sprintf(string,"X = %3d Y = %3d",ix,iy); plot_font_h(L_GREY,ScreenXs/2+4,2+high,string,FontSize,Font); val=getpt(0,ix,iy); sprintf(string,"DN = %3d",val); plot_font_h(L_GREY,ScreenXs/2+4,2+2*high,string,FontSize,Font); sprintf(string,"%3d",Hdr.lut[val].r); plot_font_h( RED,ScreenXs/2+4+10*wide,2+2*high,string,FontSize,Font); sprintf(string,"%3d",Hdr.lut[val].g); plot_font_h(GREEN,ScreenXs/2+4+14*wide,2+2*high,string,FontSize,Font); sprintf(string,"%3d",Hdr.lut[val].b); plot_font_h( BLUE,ScreenXs/2+4+18*wide,2+2*high,string,FontSize,Font); sprintf(string,"DATA"); plot_font_h(WHITE,ScreenXs/2+4,2+3*high,string,FontSize,Font); sprintf(string,"%3d",point[0]); plot_font_h( RED,ScreenXs/2+4+10*wide,2+4*high,string,FontSize,Font); sprintf(string,"%3d",point[1]); plot_font_h(GREEN,ScreenXs/2+4+14*wide,2+4*high,string,FontSize,Font); sprintf(string,"%3d",point[2]); plot_font_h( BLUE,ScreenXs/2+4+18*wide,2+4*high,string,FontSize,Font); set_xy(px,py,xaxis,yaxis,xc,yc,point,scale,size); for(k=0;k<3;k++) { tcursor_val(0,px[k],py[k],csize,pbuff[k],dark,WHITE,180); pxo[k]=px[k]; pyo[k]=py[k]; } ixo=ix; iyo=iy; } if(ans=='+'&&speed<32) speed*=2; if(ans=='-'&&speed>1) speed/=2; }while(ans!=27); uncursor(0,ixo,iyo,csize,cbuff); for(k=0;k<3;k++) uncursor(0,pxo[k],pyo[k],csize,pbuff[k]); paint_box(0,D_GREY,Outbuff,ScreenXs/2,0,22*wide,5*high+5); } /*********************************************************************** ** ** ** ** ************************************************************************/ int set_xy(x,y,xaxis,yaxis,xc,yc,point,scale,size) int *x,*y,*xaxis,*yaxis,*xc,*yc,scale,size; unsigned char *point; { int i,j,k; long dist[3]; for(k=0;k<3;k++) { dist[k]=((long)point[k]-(long)Hdr.imgmin[k])*255; dist[k]/=(long)Range[k]; dist[k]/=(long)scale; } for(k=0;k<3;k++) { x[k]=(int)dist[xaxis[k]]+xc[k]; y[k]=yc[k]+size-(int)dist[yaxis[k]]; } } /*********************************************************************** ** ** ** ** ************************************************************************/ int scan_hdrs() { int i,j,k; char type[100],string[100]; int numfile; FILE *fp; sprintf(type,"*.%c5d",VideoType); numfile=get_file_name(type,string); if(numfile<0) exit(0); fp=fopen(string,"rb"); if(!fp) { printf("Could not open '%s' to read.\n",string); exit(0); } fread((char *)&Hdr,sizeof(struct image_header),1,fp); print_hdr(); } /*********************************************************************** ** ** ** ** ************************************************************************/ int print_hdr() { int i,j,k; int black=0,white=0; printf("Source Color Image:\n"); printf(" row = %d column = %d sample rate = %d\n", Hdr.row,Hdr.col,Hdr.sample); printf("5-D Image:\n"); printf(" row = %d col = %d\n",Hdr.imgrow,Hdr.imgcol); printf("Source Images:\n"); for(k=0;k<3;k++) { printf(" %20s %3d %3d",Hdr.infile[k],Hdr.imgmin[k],Hdr.imgmax[k]); if(Hdr.negative[k]==1) printf(" (Negative)\n"); else printf("\n"); } for(i=0;i<256;i++) { if(Hdr.lut[i].r==0&&Hdr.lut[i].g==0&&Hdr.lut[i].b==0) black+=1; if(Hdr.lut[i].r==255&&Hdr.lut[i].g==255&&Hdr.lut[i].b==255) white+=1; } printf("Color Palette Contains "); if(black==1) printf("1 black"); else printf("%d blacks",black); if(white==1) printf(" and 1 white"); else printf(" and %d whites",white); } /*********************************************************************** ** ** ** ** ************************************************************************/ int process_set(lblname,name5d) char *lblname,*name5d; { int i,j,k; char name[100],string[100]; int missing=0,n; FILE *fpimg,*fppal,*fpin[3],*fpout; int sampx,sampy,sampin,sampcolor,row,col; long offsetin,offsetcolor; int xc[3],yc[3]; xc[0]=xc[2]=ScreenXs/2; xc[1]=yc[0]=0; yc[1]=yc[2]=ScreenYs/2; strcpy(name,lblname); for(k=0;ksampy)sampin=sampx; else sampin=sampy; if(sampin<1)sampin=1; offsetin=Source_Col; offsetin*=(sampin*Hdr.sample-1); printf("sample rate of 8-bit input image is %d\n",sampin); printf("sample rate of data images is %d\n",sampin*Hdr.sample); sampcolor=sampin; if(sampcolor<1)sampcolor=1; Hdr.imgrow=row=Hdr.row/sampcolor; Hdr.imgcol=col=Hdr.col/sampcolor; offsetcolor=Hdr.col; offsetcolor*=sampcolor-1; if(load_names(Image)<1) { printf("file '%s' could not be found.\n",Image); missing+=1; } if(load_names(Palette)<1) { printf("file '%s' could not be found.\n",Palette); missing+=1; } for(k=0;k<3;k++) { if(load_names(Hdr.infile[k])<1) { printf("file '%s' could not be found.\n",Hdr.infile[k]); missing+=1; } } if(missing>0) exit(0); video_on(); fppal=fopen(Palette,"rt"); { for(i=0;i<256;i++) if(fscanf(fppal,"%d%d%d%d", &n,&Hdr.lut[i].r,&Hdr.lut[i].g,&Hdr.lut[i].b)<4) { printf("'%s' did not have 256 entries.\n",Palette); video_off(); exit(0); } WritePalette(Hdr.lut); } fclose(fppal); fwrite((char *)&Hdr,sizeof(struct image_header),1,fpout); fpimg=fopen(Image,"rb"); for(i=0;i1) { for(j=0;j1) { for(j=0;jHdr.imgmax[k]) Hdr.imgmax[k]=Buffer[k][j]; if((int)Buffer[k][j]1) VideoType='Y'; } } if(VideoType=='V') { ret=SetVideoMode(0x12,&B_Id); strcpy(SubType,".vmg"); } if(VideoType=='Y') { ret=SetVideoMode(400,&B_Id); strcpy(SubType,".ymg"); ScreenXs=640; ScreenYs=400; } if(VideoType=='S') { ret=SetVideoMode(0x13,&B_Id); strcpy(SubType,".smg"); ScreenXs=320; ScreenYs=200; FontSize=3; } if(ret>=0) return(1); else { SetVideoMode(0,&B_Id); printf("Could not boot video board\n\n"); exit(0); } } /******************************************************************** ** ** ** ********************************************************************* */ int video_off() { SetVideoMode(0,&B_Id); } /*********************************************************************** ** ** ** ** ************************************************************************/ int check_hdr() { int i,j,k; for(i=0;i<3;i++) { if(strlen(Hdr.infile[i])<1) { printf("'CHANNEL_INPUT:' heading was not found."); printf(" Use 'IMVIS' to create an image set.\n"); exit(0); } } if(strlen(Palette)<1) { printf("'PAL_POINTER' heading was not found."); printf(" Use 'IMVIS' to create an image set.\n"); exit(0); } if(strlen(Image)<1) { printf("'IMAGE_POINTER' heading was not found."); printf(" Use 'IMVIS' to create an image set.\n"); exit(0); } printf("row = %3d column = %3d sample = %d\n",Hdr.row,Hdr.col,Hdr.sample); printf("Input Files:\n"); for(i=0;i<3;i++) { printf(" %s",Hdr.infile[i]); if(Hdr.negative[i]==1) printf(" (Negative)\n"); else printf("\n"); } printf("Image file = '%s'\n",Image); printf("Color palette = '%s'\n",Palette); } /*********************************************************************** ** ** return: ** ** -1 = '.lbl' file not found ** -2 = row < 1 ** -3 = col < 1 or col >= MAXSIZE ** -4 = numimage < 2 || numimage >= MAXCOL ** -5 = hit end of file while reading image names ** -6 = could not open image file ** -7 = bad data_max/min values ** ************************************************************************/ int read_lbl(name) char *name; { int i,j,k; char string[100],str1[100],str2[100],str3[100]; int i1,i2,i3,ret; FILE *fp; strcpy(string,name); for(k=0;kMAXSIZE) return(-3); Source_Col=Hdr.col; } if(strcmpi(str1,"SOURCE_ROW")==0) sscanf(string,"%s%s%d",str1,str2,&Source_Row); if(strcmpi(str1,"SOURCE_COL")==0) sscanf(string,"%s%s%d",str1,str2,&Source_Col); if(strcmpi(str1,"HEADER_BYTES")==0) { printf("HEADER_BYTES are not allowed.\n"); exit(0); } if(strcmpi(str1,"SET_POINTER")==0) { printf( "'SET_POINTER' is not allowed -- should be 'CHANNEL_INPUT:'.\n"); exit(0); } if(strcmpi(str1,"SAMPLE_RATE")==0) { sscanf(string,"%s%s%d",str1,str2,&Hdr.sample); } if(strcmpi(str1,"CHANNEL_INPUT:")==0) { for(i=0;i<3;i++) { if(!fgets(string,99,fp)) { printf("EOF while reading input file names.\n"); exit(0); } sscanf(string,"%s%s%s",str1,str2,str3); if(strcmpi(str1,"RED")==0) k=0; else if(strcmpi(str1,"GREEN")==0) k=1; else if(strcmpi(str1,"BLUE")==0) k=2; else { printf( "'%s' is not a valid channel color: Must be RED, GREEN or BLUE\n"); exit(0); } strcpy(Hdr.infile[k],str3); Hdr.negative[k]=0; for(j=0;j=0&&last_slashcolon-1) { string[len]='.'; dot=len; len+=1; string[len]='\0'; } if(colon>0) disk=string[0]; if(first_slash>=0) { for(i=first_slash;i<=last_slash;i++) path[i-first_slash]=string[i]; path[last_slash-first_slash+1]='\0'; } if(last_slash>0&&last_slash0) { for(i=last_slash+1;i0&&last_slash<0&&dot>0) /* d:test.img */ { for(i=colon+1;i0) /* test.img */ { for(i=0;i0&&dot3) type[3]='\0'; } return(disk); }