Utah Raster Toolkit  9999-git
URT Development version (post-3.1b)
Functions | Variables
rlebox.c File Reference
#include <stdio.h>
#include "rle.h"
#include "rle_raw.h"
Include dependency graph for rlebox.c:

Go to the source code of this file.

Functions

void main (int argc, char **argv)
 

Variables

static char rcsid [] = "$Header: /l/spencer/src/urt/tools/RCS/rlebox.c,v 3.0.1.3 1992/04/30 14:11:24 spencer Exp $"
 

Function Documentation

void main ( int  argc,
char **  argv 
)

Definition at line 44 of file rlebox.c.

47 {
48  extern void rle_box();
50  char * rlefname = NULL;
51  int vflag = 0, cflag = 0, margin = 0;
52  int xmin, xmax, ymin, ymax;
53  int rle_cnt, rle_err;
54 
55  if ( scanargs( argc, argv, "% v%- c%- m%-margin!d infile%s",
56  &vflag, &cflag, &margin, &margin,
57  &rlefname ) == 0 )
58  exit( 1 );
59 
60  the_hdr = *rle_hdr_init( (rle_hdr *)NULL );
61  rle_names( &the_hdr, cmd_name( argv ), rlefname, 0 );
62  the_hdr.rle_file = rle_open_f(the_hdr.cmd, rlefname, "r");
63 
64  for ( rle_cnt = 0;
65  (rle_err = rle_get_setup( &the_hdr )) == RLE_SUCCESS;
66  rle_cnt++ )
67  {
68 
69  rle_box( &the_hdr, &xmin, &xmax, &ymin, &ymax );
70 
71  /* If margin, enlarge bounds. Don't let them go negative */
72  if ( margin )
73  {
74  xmax += margin;
75  ymax += margin;
76  xmin -= margin;
77  if ( xmin < 0 )
78  xmin = 0;
79  ymin -= margin;
80  if ( ymin < 0 )
81  ymin = 0;
82  }
83 
84  if ( cflag )
85  printf( vflag ? "xmin=%d ymin=%d xmax=%d ymax=%d\n" :
86  "%d %d %d %d\n",
87  xmin, ymin, xmax, ymax );
88  else
89  printf( vflag ? "xmin=%d xmax=%d ymin=%d ymax=%d\n" :
90  "%d %d %d %d\n",
91  xmin, xmax, ymin, ymax );
92  }
93 
94  /* Check for an error. EOF or EMPTY is ok if at least one image
95  * has been read. Otherwise, print an error message.
96  */
97  if ( rle_cnt == 0 || (rle_err != RLE_EOF && rle_err != RLE_EMPTY) )
98  rle_get_error( rle_err, the_hdr.cmd, rlefname );
99 
100  exit( 0 );
101 }
rle_hdr the_hdr
Definition: aliastorle.c:100
int scanargs(int argc, char **argv, const char *format,...)
Definition: scanargs.c:94
#define RLE_EMPTY
Definition: rle.h:73
#define RLE_SUCCESS
Definition: rle.h:70
void rle_names(rle_hdr *the_hdr, const char *pgmname, const char *fname, int img_num)
const char * cmd
Definition: rle.h:133
int rle_get_setup(rle_hdr *the_hdr)
Definition: rle_getrow.c:74
Definition: rle.h:96
int rle_get_error(int code, const char *pgmname, const char *fname)
#define RLE_EOF
Definition: rle.h:74
FILE * rle_open_f(const char *prog_name, const char *f_name, const char *mode)
int cflag
Definition: getgmr.c:19
char * cmd_name(char **argv)
Definition: cmd_name.c:31
void rle_box()
FILE * rle_file
Definition: rle.h:114
rle_hdr * rle_hdr_init(rle_hdr *the_hdr)
Definition: rle_hdr.c:267

Variable Documentation

char rcsid[] = "$Header: /l/spencer/src/urt/tools/RCS/rlebox.c,v 3.0.1.3 1992/04/30 14:11:24 spencer Exp $"
static

Definition at line 10 of file rlebox.c.