FUNCTION wasp_write_hdr,outdir,imgname,ncols,nrows,d ;+ ;Reads the header file associated with a .img file and ;returns the number of columns, number of rows, and the ;data type. ;- success=-1 dot=strpos(imgname,'.',/REVERSE_SEARCH) slash=strpos(imgname,'\',/REVERSE_SEARCH) basedir=strmid(imgname,0,slash+1) basename=STRMID(imgname,slash+1,dot-slash-1) header1=basedir+basename + '.hdr' openr,1,header1 ;Open an output header file header2=outdir+basename+'c.hdr' print,'output file= ',header2 openw,2,header2 ;Find the image data WHILE NOT EOF(1) DO BEGIN s='' pstate=0 readf,1,s s=strlowcase(s) if strpos(s,'samples') GE 0 then begin printf,2,'samples = ',ncols pstate=1 endif if strpos(s,'lines') GE 0 then begin printf,2,'lines = ',nrows pstate=1 endif if strpos(s,'data type') GE 0 then begin printf,2,'data type = ',d pstate=1 endif if pstate eq 0 then printf,2,s ENDWHILE close,1 close,2 if ncols gt 0 and nrows gt 0 and d ge 0 then success=1 return,success end ;wasp_write_hdr