Utah Raster Toolkit  9999-git
URT Development version (post-3.1b)
Macros | Functions
getiris.c File Reference
#include "gl.h"
#include "device.h"
#include "stdio.h"
#include "rle.h"
Include dependency graph for getiris.c:

Go to the source code of this file.

Macros

#define MIN(a, b)   ( a<b ? a : b)
 

Functions

 main (int argc, char **argv)
 

Macro Definition Documentation

#define MIN (   a,
  b 
)    ( a<b ? a : b)

Definition at line 13 of file getiris.c.

Function Documentation

main ( int  argc,
char **  argv 
)

Definition at line 20 of file getiris.c.

23 {
24  rle_hdr hdr;
25  char *infname;
26  int x_len, y_len;
27  int i;
28  unsigned char **scan;
29  Device val;
30 
31  hdr = *rle_hdr_init( (rle_hdr *)NULL );
32 
33  if ( scanargs( argc, argv, "% infile%s\n(\
34 \tDisplay on SGI not running a window manager.)",
35  &infname ) == 0 )
36  exit( 1 );
37 
38  rle_names( &hdr, cmd_name( argv ), infname, 0 );
39 
40  /* This program runs without mex running. */
41  if ( ismex())
42  {
43  fprintf( stderr, "%s: can't run under mex!\n", hdr.cmd);
44  exit(0);
45  }
46  ginit();
47 
48  /* Turn off cursor so that picture doesn't have a glich. */
49  cursoff();
50  RGBmode();
51  gconfig();
52  RGBcolor(0, 0, 0);
53  clear();
54 
55  /* Setup mouse buttons so that they are queued. */
56  qdevice( LEFTMOUSE );
57  qdevice( RIGHTMOUSE );
58  qdevice( MIDDLEMOUSE );
59  qreset();
60 
61  /* Take input from file argument or stdin. */
62  hdr.rle_file = rle_open_f(hdr.cmd, infname, "r");
63  rle_get_setup( &hdr );
64 
65  x_len = hdr.xmax - hdr.xmin + 1;
66  y_len = hdr.ymax - hdr.ymin + 1;
67  hdr.xmax -= hdr.xmin;
68  hdr.xmin = 0;
69 
70  /* Grab a scanline. */
71  scan = (unsigned char **) malloc( (hdr.ncolors +
72  hdr.alpha) *
73  sizeof( unsigned char * ) );
74  for ( i = 0; i < hdr.ncolors + hdr.alpha; i++ )
75  scan[i] = (unsigned char *)malloc( x_len );
76 
77  if ( hdr.alpha )
78  {
79  scan++;
80  }
81 
82  /* Display each scanline. */
83  for ( i = 0; i < MIN(y_len,768) ; i ++)
84  {
85  rle_getrow(&hdr, scan );
86 
87  cmov2i(0, i);
88  writeRGB(x_len, scan[0], scan[1], scan[2]);
89  }
90 
91  /* Wait for a mouse button push. */
92  qread( &val);
93 
94  /* Set the iris back up so that it is not scrogged. */
95  singlebuffer();
96  gconfig();
97  clear();
98  gexit();
99 }
int xmin
Definition: rle.h:100
int scanargs(int argc, char **argv, const char *format,...)
Definition: scanargs.c:94
rle_hdr hdr
Definition: iristorle.c:35
int ymin
Definition: rle.h:100
unsigned char ** scan
Definition: rle.c:26
string infname
Definition: getbob.c:68
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 xmax
Definition: rle.h:100
#define MIN(a, b)
Definition: getiris.c:13
int ymax
Definition: rle.h:100
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)
char * cmd_name(char **argv)
Definition: cmd_name.c:31
int rle_getrow(rle_hdr *the_hdr, rle_pixel *scanline[])
FILE * rle_file
Definition: rle.h:114
int ncolors
Definition: rle.h:100
rle_hdr * rle_hdr_init(rle_hdr *the_hdr)
Definition: rle_hdr.c:267