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

Go to the source code of this file.

Functions

void main (int argc, argv)
 

Variables

static char rcs_ident [] = "$Id: rlesetbg.c,v 3.0.1.1 1992/01/23 20:44:32 spencer Exp $"
 
char buffer [4096]
 

Function Documentation

void main ( int  argc,
argv   
)

Definition at line 38 of file rlesetbg.c.

41 {
42  int *new_back = NULL, nback = 0;
43  int overlay_flag = 0, backcolor_flag = 0, oflag = 0;
45  char * fname = NULL, *out_fname = NULL;
46  FILE *outfile = stdout;
47  int rle_cnt, rle_err;
48 
49  in_hdr = *rle_hdr_init( NULL );
50  out_hdr = *rle_hdr_init( NULL );
51 
52  if (scanargs(argc, argv,
53  "% DO%- c%-bgcolor!*d o%-outfile!s infile%s",
54  &overlay_flag, &backcolor_flag,
55  &nback, &new_back,
56  &oflag, &out_fname, &fname ) == 0)
57  {
58  exit(-1);
59  }
60  if (overlay_flag == 2 && backcolor_flag)
61  {
62  fprintf(stderr, "%s: Delete or new color, but not both\n",
63  cmd_name( argv ));
64  exit(-1);
65  }
66  in_hdr.rle_file = rle_open_f(cmd_name( argv ), fname, "r");
67  rle_names( &in_hdr, cmd_name( argv ), fname, 0 );
68  rle_names( &out_hdr, in_hdr.cmd, out_fname, 0 );
69 
70  for ( rle_cnt = 0;
71  (rle_err = rle_get_setup( &in_hdr )) == RLE_SUCCESS;
72  rle_cnt++ )
73  {
74  if ( backcolor_flag && nback < in_hdr.ncolors )
75  {
76  fprintf( stderr, "Need %d colors, only %d supplied.\n",
77  in_hdr.ncolors, nback );
78  exit(-1);
79  }
80  (void)rle_hdr_cp( &in_hdr, &out_hdr );
81  if ( rle_cnt == 0 )
82  outfile = rle_open_f( cmd_name( argv ), out_fname, "w" );
83  out_hdr.rle_file = outfile;
84 
85  rle_addhist( argv, &in_hdr, &out_hdr );
86 
87  out_hdr.background = 2 - overlay_flag;
88  if ( backcolor_flag != 0 )
89  out_hdr.bg_color = new_back;
90 
91  rle_put_setup( &out_hdr );
92 
93  rle_cp( &in_hdr, &out_hdr );
94  }
95 
96  /* Check for an error. EOF or EMPTY is ok if at least one image
97  * has been read. Otherwise, print an error message.
98  */
99  if ( rle_cnt == 0 || (rle_err != RLE_EOF && rle_err != RLE_EMPTY) )
100  rle_get_error( rle_err, cmd_name( argv ), fname );
101 
102  exit( 0 );
103 }
int scanargs(int argc, char **argv, const char *format,...)
Definition: scanargs.c:94
static rle_hdr in_hdr
Definition: rletogif.c:37
FILE * outfile
Definition: giftorle.c:61
#define RLE_EMPTY
Definition: rle.h:73
void rle_cp(rle_hdr *in_hdr, rle_hdr *out_hdr)
Definition: rle_cp.c:69
int * bg_color
Definition: rle.h:100
void rle_addhist(char *argv[], rle_hdr *in_hdr, rle_hdr *out_hdr)
#define RLE_SUCCESS
Definition: rle.h:70
char * fname[3]
Definition: show3.c:31
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
int background
Definition: rle.h:100
rle_hdr * rle_hdr_cp(rle_hdr *from_hdr, rle_hdr *to_hdr)
Definition: rle_hdr.c:119
FILE * rle_open_f(const char *prog_name, const char *f_name, const char *mode)
void rle_put_setup(rle_hdr *the_hdr)
Definition: rle_putrow.c:453
char * cmd_name(char **argv)
Definition: cmd_name.c:31
int oflag
Definition: painttorle.c:45
int overlay_flag
Definition: read98721.c:61
FILE * rle_file
Definition: rle.h:114
rle_hdr out_hdr
Definition: dvirle2.c:89
int ncolors
Definition: rle.h:100
rle_hdr * rle_hdr_init(rle_hdr *the_hdr)
Definition: rle_hdr.c:267

Variable Documentation

char buffer[4096]

Definition at line 35 of file rlesetbg.c.

Referenced by update_zoom().

char rcs_ident[] = "$Id: rlesetbg.c,v 3.0.1.1 1992/01/23 20:44:32 spencer Exp $"
static

Definition at line 29 of file rlesetbg.c.