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

Go to the source code of this file.

Functions

 main (int argc, char **argv)
 

Function Documentation

main ( int  argc,
char **  argv 
)

Definition at line 19 of file getqcr.c.

22 {
23  rle_hdr hdr;
24  rle_pixel * camera_data = NULL, * cdptr;
25  rle_pixel ** rows;
26  char * filename;
27  int color = 0;
28  int y, i, ysize;
29  int verbose_flag = 0, double_flag = 0, exposures = 1, exp_flag = 0;
30  int center_flag = 0, pos_flag = 0, fourK = 0, xstart = 0, ystart = 0;
31 
32  if (! scanargs( argc, argv,
33  "% v%- d%- c%- f%- p%-xpos!dyposn!d e%-num!d infile!s",
34  &verbose_flag, &double_flag, &center_flag,
35  &fourK, &pos_flag, &xstart, &ystart,
36  &exp_flag, &exposures, &filename ))
37  exit(-1);
38 
39  hdr = *rle_hdr_init( (rle_hdr *)NULL );
40  rle_names( &hdr, cmd_name( argv ), filename );
41 
42  hdr.ncolors = 1; /* Assume at least one */
43  init_qcr( verbose_flag );
44 
45  if (double_flag)
46  exposures = 2;
47 
48  while( color < hdr.ncolors )
49  {
50  hdr.rle_file = rle_open_f( hdr.cmd, filename, "r" );
51  if ( hdr.ncolors > 1 &&
52  hdr.rle_file == stdin &&
53  fseek( hdr.rle_file, 0L, 0 ) < 0 )
54  {
55  fprintf( "Can't pipe color data to %s.\n", hdr.cmd );
56  exit( -1 );
57  }
58 
59  rle_get_setup_ok( &hdr, NULL, NULL );
60 
61  if (! pos_flag)
62  {
63  xstart = hdr.xmin;
64  ystart = hdr.ymin;
65  }
66 
67  hdr.xmax -= hdr.xmin;
68  hdr.xmin = 0;
69  ysize = (hdr.ymax - hdr.ymin + 1);
70 
71  if (! camera_data) /* Only allocate once */
72  {
73  rows = (rle_pixel **) malloc( hdr.ncolors
74  * sizeof( rle_pixel * ));
75  camera_data = (rle_pixel *)
76  malloc( (hdr.xmax + 1) * ysize);
77 
78  RLE_CHECK_ALLOC( hdr.cmd, rows && camera_data, "image memory" )
79  }
80 
81  /* Only read one color at a time, never alpha */
82  for (i = -hdr.alpha; i < hdr.ncolors; i++)
83  RLE_CLR_BIT( hdr, i );
84  RLE_SET_BIT( hdr, color );
85 
86  rows[color] = camera_data;
87 
88  if (center_flag)
89  set_up_qcr( hdr.xmax + 1, ysize, ysize, 0 );
90  else
92  hdr.xmax + 1, ysize, fourK );
93 
94  for (y = hdr.ymin; y <= hdr.ymax; y++)
95  {
96  rle_getrow( &hdr, rows );
97  rows[color] = &(rows[color][hdr.xmax+1]);
98  }
99 
100  for ( i = 0; i < exposures; i++)
101  send_pixel_image( color, camera_data,
102  (hdr.xmax + 1) * ysize);
103 
104  fclose( hdr.rle_file );
105  color++;
106  }
107  exit( 0 );
108 }
#define RLE_SET_BIT(glob, bit)
Definition: rle.h:122
int xmin
Definition: rle.h:100
int scanargs(int argc, char **argv, const char *format,...)
Definition: scanargs.c:94
int init_qcr(short verbose)
Definition: qcr.c:104
Boolean verbose_flag
Definition: getx11.c:80
send_pixel_image(int color, char *buff, int len)
Definition: qcr.c:403
rle_hdr hdr
Definition: iristorle.c:35
int ymin
Definition: rle.h:100
int ystart
Definition: read98721.c:51
static int y
Definition: getami.c:691
int xstart
Definition: read98721.c:50
void rle_names(rle_hdr *the_hdr, const char *pgmname, const char *fname, int img_num)
const char * cmd
Definition: rle.h:133
Definition: rle.h:96
int xmax
Definition: rle.h:100
rle_pixel ** rows
Definition: rletopaint.c:57
set_up_qcr_nc(xstart, ystart, xsize, ysize, fourK)
Definition: qcr.c:354
#define RLE_CLR_BIT(glob, bit)
Definition: rle.h:124
int ymax
Definition: rle.h:100
int ysize
Definition: read98721.c:59
unsigned char rle_pixel
Definition: rle.h:56
void * malloc()
int i
Definition: rletorla.c:82
int alpha
Definition: rle.h:100
FILE * rle_open_f(const char *prog_name, const char *f_name, const char *mode)
set_up_qcr(int x_size, int y_size, int nslice, int offset)
Definition: qcr.c:303
char * cmd_name(char **argv)
Definition: cmd_name.c:31
boolean pos_flag
Definition: getbob.c:84
void rle_get_setup_ok(rle_hdr *the_hdr, const char *prog_name, const char *file_name)
int rle_getrow(rle_hdr *the_hdr, rle_pixel *scanline[])
FILE * rle_file
Definition: rle.h:114
int ncolors
Definition: rle.h:100
#define RLE_CHECK_ALLOC(pgm, ptr, name)
Definition: rle.h:86
rle_hdr * rle_hdr_init(rle_hdr *the_hdr)
Definition: rle_hdr.c:267