/* greyimg.c gi1.bat = cl /AL greyimg.c getfile3 Makes a grey (or any other color image) for editing vectors with imvis and makes the '.xyc' file. greyimg [image_name] [maxlat] [minlat] [maxlon] [minlon] */ #include #include #include "nomouse.h" #define DEG_RAD 0.01745329251 /* converts degrees to radians */ #define NUMRED 6 #define NUMGRN 6 #define NUMBLU 5 int ScreenXs=640,ScreenYs=480; 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}; struct file_stat { float maxlat,minlat,maxlon,minlon; }Fs; unsigned char Buffer[640]; int xy2ll(float x,float y,float *lat,float *lon,float lat0,float lon0, float latpp,float lonpp); main(int argc,char *argv[]) { int i,j,k,n,r,g,b; float maxlat,minlat,maxlon,minlon,midlat; float latrange,lonrange; float x,y,lat,lon; float coslat,latperpix,lonperpix,lat0,lon0; char string[100],name[100]; FILE *fplbl,*fppal,*fpdat,*fpxyc,*fpbin; int row,col; printf("\n\n\n\n\n\n\n\n\n"); printf("Program 'GREYIMG' makes a grey image\n"); printf(" which allows you to edit raw files \n"); printf("using the program 'IMVIS' \"Digitize\"\n"); printf("option. To use this program you must 1st run \n"); printf("reorder on the raw file to make the binary \n"); printf("file set.\n\n"); printf("WARNING!!!!!\n"); printf("\n"); printf("THIS PROGRAM WILL OVERWRITE ANY XYC FILE\n"); printf("WHICH HAS THE SAME NAME AS THE RAW FILE!\n"); printf("\n"); printf("reorder test p -- makes binary files\n"); printf("greyimg -- makes: test.LBL,\n"); printf(" test.PAL, test.DAT\n"); printf(" and test.XYC\n"); printf("xy -- makes new test.XYC\n\n\n\n"); if(get_file_name("*.hdr",string)<0) { printf("No files present or chosen.\n\n"); exit(0); } strcpy(name,string); for(k=0;klonperpix) { lonperpix=latperpix/coslat; } else { lonperpix*=coslat; latperpix=lonperpix*coslat; } col=lonrange/lonperpix+1; row=latrange/latperpix+1; printf("row = %d\n",row); printf("col = %d\n",col); sprintf(string,"%s.lbl",name); fplbl=fopen(string,"wt"); if(!fplbl) not_open(string,"write"); fprintf(fplbl,"FILE_TYPE = IMAGE\n"); fprintf(fplbl,"IMAGE_LINES = %6d\n",row); fprintf(fplbl,"LINE_SAMPLES = %6d\n",col); fprintf(fplbl,"SCAN_RATE = 150 dots/inch\n"); fprintf(fplbl,"IMAGE_POINTER = '%s.dat'\n",name); fprintf(fplbl,"PAL_POINTER = '%s.pal'\n",name); fprintf(fplbl,"END\n"); fclose(fplbl); sprintf(string,"%s.pal",name); fppal=fopen(string,"wt"); if(!fppal) not_open(string,"write"); for(i=0;i<64;i++) fprintf(fppal,"%3d %3d %3d %3d\n",i,i*4,i*4,i*4); n=64; for(r=0;rmaxlat=fs->maxlon=-720.0; fs->minlat=fs->minlon= 720.0; fread((char *)&numsec,sizeof(int),1,fphdr); for(i=0;iminlon) fs->minlon=mnln; if(mxln>fs->maxlon) fs->maxlon=mxln; if(mnltminlat) fs->minlat=mnlt; if(mxlt>fs->maxlat) fs->maxlat=mxlt; } fclose(fphdr); return(1); } /********************************************************************** ** ** ** **********************************************************************/ int not_open(char *filename,char *action) { printf("Could not open '%s' to %s.\n\n",filename,action); exit(0); }