Utah Raster Toolkit  9999-git
URT Development version (post-3.1b)
getiris.c
Go to the documentation of this file.
1 /*
2  * getiris.c - Whoop up an rle with 24 bits ( no mex ).
3  *
4  * Author: Glenn McMinn
5  * Computer Science Dept.
6  * University of Utah
7  * Date: Tue Feb 3 1987
8  * Copyright (c) 1987 Glenn McMinn
9  *
10  */
11 
12 
13 #define MIN(a,b) ( a<b ? a : b)
14 
15 #include "gl.h"
16 #include "device.h"
17 #include "stdio.h"
18 #include "rle.h"
19 
21 int argc;
22 char **argv;
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 }
FILE * rle_open_f(char *prog_name, char *file_name, char *mode)
Definition: rle_open_f.c:216
#define MIN(x, y)
Definition: rletopaint.c:53
int xmin
Definition: rle.h:100
void rle_names(rle_hdr *the_hdr, const char *pgmname, const char *fname, int img_num)
Definition: rle_hdr.c:48
char * cmd_name(char **argv)
Definition: cmd_name.c:31
void main(int argc, char **argv)
Definition: aliastorle.c:121
int rle_get_setup(rle_hdr *the_hdr)
Definition: rle_getrow.c:74
int rle_getrow(rle_hdr *the_hdr, scanline)
Definition: rle_getrow.c:333
int ymin
Definition: rle.h:100
int scanargs(int argc, char **argv, const char *format,...)
Definition: scanargs.c:94
const char * cmd
Definition: rle.h:133
int xmax
Definition: rle.h:100
int ymax
Definition: rle.h:100
int alpha
Definition: rle.h:100
rle_hdr * rle_hdr_init(rle_hdr *the_hdr)
Definition: rle_hdr.c:267
FILE * rle_file
Definition: rle.h:114
int ncolors
Definition: rle.h:100