61 static char FORMAT[80];    
 
   78 static char INTFMT[80];    
 
   79 static char REALFMT[80];   
 
   82 static char DAT_TIM[80];   
 
   83 static char COMMENT[80];   
 
   86 WriteVICARHeader(fd, width, height, BandsPerPixel)
 
   88 int width, height, BandsPerPixel;
 
  104     buffer = (
char *)malloc( 
LBLSIZE );
 
  107 #define incr(bp,fudge) 
  109     if ( bp - buffer + fudge > LBLSIZE ) 
  111     bp = buffer = realloc( buffer, LBLSIZE += width ); 
  115     sprintf(bp,
"LBLSIZE=%-d ",
LBLSIZE); 
 
  117     sprintf(bp,
" FORMAT='BYTE'");
 
  119     sprintf(bp,
" TYPE='IMAGE'");
 
  121     sprintf(bp,
" BUFSIZ=%-d",20*
LBLSIZE);
 
  123     sprintf(bp,
" DIM=3");
 
  125     sprintf(bp,
" EOL=0");
 
  127     sprintf(bp,
" RECSIZE=%-d",
LBLSIZE);
 
  129     sprintf(bp,
" ORG='BSQ'");
 
  131     sprintf(bp,
" NL=%-d",height);
 
  133     sprintf(bp,
" NS=%-d",width);
 
  137     sprintf(bp,
" N1=%-d",height);
 
  139     sprintf(bp,
" N2=%-d",width);
 
  145     sprintf(bp,
" NBB=0");
 
  147     sprintf(bp,
" NLB=0");
 
  149     sprintf(bp,
" COMMENT='created by rletovcr'");
 
  155     sprintf( buffer, 
"LBLSIZE=%-d", 
LBLSIZE );
 
  157     while ( bp < buffer + 
LBLSIZE )
 
  160     fwrite( buffer, 1, 
LBLSIZE, fd );
 
  164 static void WriteVICARScanLine(fd, VICARScanLine, VICARScanLineLength)
 
  166 unsigned char *VICARScanLine;
 
  167 int VICARScanLineLength;
 
  169     (
void)fwrite(VICARScanLine, 1, VICARScanLineLength, fd);
 
  172 static unsigned char *
 
  173 read_image( the_hdr )
 
  177     unsigned char *VICARImage;
 
  189          "%s: Only black & white images can be converted to VICAR.\n",
 
  192         fprintf( stderr, 
"\t%s has %d colors.\n",
 
  195         fprintf( stderr, 
"\t%s has a color map.\n",
 
  203     width = the_hdr
->xmax + 1;
 
  206     VICARImage = (
unsigned char *) malloc(width * height);
 
  212     rows[0] = VICARImage + width * (the_hdr
->ymax - y);
 
  221 write_image( the_hdr, outFD, VICARImage )
 
  224 unsigned char *VICARImage;
 
  226     int width, height, y;
 
  228     if (
VERBOSE) fprintf(stderr,
"%s: Writing VICARHeader\n", the_hdr
->cmd);
 
  232     WriteVICARHeader(outFD, width, height, the_hdr
->ncolors);
 
  234     if (
VERBOSE) fprintf(stderr,
"%s: Writing VICAR image", the_hdr
->cmd);
 
  236     for ( y = 0; y < height; y++ )
 
  238     WriteVICARScanLine(outFD, VICARImage + y * width, width);
 
  239     if (
VERBOSE) fprintf(stderr,
".");
 
  242     if (
VERBOSE) fprintf(stderr,
"\n");
 
  245     fprintf(stderr,
"%s: Error writing image\n", the_hdr
->cmd);
 
  248     fprintf(stderr,
"%s: finished writing the image\n", the_hdr
->cmd);
 
  257     char *infname = NULL, outfname = NULL;
 
  259     unsigned char *VICARImage;
 
  263     if ( 
scanargs( argc
, argv
, "% v%- o%-outfile!s infile%s\n(\ 
  264 \tConvert URT image to VICAR format (as currently understood).)", 
  269     rle_names( &the_hdr, cmd_name( argv ), infname );
 
  273     VICARImage = read_image( &the_hdr );
 
  277     write_image( &the_hdr, outFD, VICARImage );
 
FILE * rle_open_f(char *prog_name, char *file_name, char *mode)
 
void main(int argc, char **argv)
 
int rle_getrow(rle_hdr *the_hdr, scanline)
 
int scanargs(int argc, char **argv, const char *format,...)
 
void rle_get_setup_ok(rle_hdr *the_hdr, const  char *prog_name, const  char *file_name)
 
#define RLE_CLR_BIT(glob, bit)
 
rle_hdr * rle_hdr_init(rle_hdr *the_hdr)
 
#define RLE_CHECK_ALLOC(pgm, ptr, name)