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

Go to the source code of this file.

Macros

#define MIN(a, b)   ( a<b ? a : b)
 
#define RASTERHEIGHT   1024 /* Calling inquire_sizes is just too tedious */
 

Functions

 main (int argc, argv)
 

Variables

int display_flag = FALSE
 
int driver_flag = FALSE
 
char * display_name = "/dev/crt"
 
char * driver_name = "hp98721"
 

Macro Definition Documentation

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

Definition at line 14 of file getren.c.

#define RASTERHEIGHT   1024 /* Calling inquire_sizes is just too tedious */

Definition at line 24 of file getren.c.

Function Documentation

main ( int  argc,
argv   
)

Definition at line 26 of file getren.c.

28 {
29  int fildes;
30  int x_len, y_len, x_off = 0, y_off = 0;
31  int i, j, map_offset ;
32  rle_hdr hdr;
33  unsigned char **scan;
34  char * filename = NULL;
35  int over_flag = 0;
36  int pos_flag = 0;
37  float tmp;
38  float colors[256][3];
39  gescape_arg arg1, arg2;
40 
41  if (! scanargs( argc, argv,
42  "% pP%-xpos!dypos!d O%- d%-display!s x%-driver!s infile%s",
43  &pos_flag, &x_off, &y_off, &over_flag,
46  &filename ))
47  exit( -1 );
48 
49  hdr = *rle_hdr_init( (rle_hdr *)NULL );
50  rle_names( &hdr, cmd_name( argv ), filename, 0 );
51 
52  if (! over_flag)
53  over_flag = INIT;
54 
55  if (( fildes = gopen(display_name, OUTDEV,
56  driver_name, over_flag )) < 0)
57  fprintf(stderr, "%s: can't open %s\n", hdr.cmd, display_name);
58 
59  hdr.rle_file = rle_open_f(hdr.cmd, filename, "r");
60 
61  rle_get_setup_ok( &hdr, NULL, NULL );
62 
63  /* So we see the whole FB. */
64  clip_indicator( fildes, CLIP_OFF );
65 
66  arg1.i[0] = FALSE;
67  gescape( fildes, SWITCH_SEMAPHORE, &arg1, &arg2 );
68 
69  /* This version assumes a full 24-bit machine */
70  shade_mode( fildes, CMAP_FULL, 0 );
71 
72  if ( hdr.ncmap ) /* Use colormap in file */
73  {
74  map_offset = 1 << hdr.cmaplen;
75  if (hdr.ncmap == 3)
76  {
77  for (i = 0; i < 256; i++)
78  {
79  colors[i][0] = (float) ((hdr.cmap[i] >>8) & 0xFF)
80  / 255.0;
81  colors[i][1] = (float) ((hdr.cmap[i+map_offset] >>8)
82  & 0xFF) / 255.0;
83  colors[i][2] = (float) ((hdr.cmap[i+2*map_offset]>>8)
84  & 0xFF) / 255.0;
85  }
86  }
87  else
88  if (hdr.ncmap == 1)
89  {
90  for (i = 0; i < 256; i++)
91  {
92  tmp = (float) ((hdr.cmap[i] >> 8) * 0xFF);
93  colors[i][0] = tmp;
94  colors[i][1] = tmp;
95  colors[i][2] = tmp;
96  }
97  }
98  else
99  {
100  fprintf(stderr, "%s: Sorry, don't grock %d channel color maps\n",
101  hdr.cmd, hdr.ncmap);
102  exit(-1);
103  }
104  }
105  else
106  {
107  /* Set the color map to default */
108  for (i = 0; i < 256; i++)
109  {
110  tmp = (float) i / 255.0;
111  colors[i][0] = tmp;
112  colors[i][1] = tmp;
113  colors[i][2] = tmp;
114  }
115  }
116  define_color_table( fildes, 0, 256, colors );
117 
118  x_len = hdr.xmax - hdr.xmin + 1;
119  y_len = hdr.ymax - hdr.ymin + 1;
120  if (pos_flag)
121  {
122  if (pos_flag == 1) /* -P, incremental position */
123  {
124  x_off = hdr.xmin + x_off;
125  y_off += hdr.ymin;
126  }
127  }
128  else
129  {
130  x_off = hdr.xmin;
131  y_off = hdr.ymin;
132  }
133 
134  y_off = RASTERHEIGHT - y_off - 1; /* Invert origin */
135 
136  /* This gets rid of the left margin slop in the scanline. */
137  hdr.xmax -= hdr.xmin;
138  hdr.xmin = 0;
139 
140  if (rle_row_alloc( &hdr, &scan ) < 0)
141  RLE_CHECK_ALLOC( hdr.cmd, 0, "image memory" );
142 
143  /* Display each scanline. */
144 
145  y_len = MIN( RASTERHEIGHT-1, y_len );
146  for ( i = 0; i < y_len ; i ++)
147  {
148  rle_getrow(&hdr, scan );
149 
150  for (j = RLE_RED; j < hdr.ncolors; j++)
151  {
152  /* HP numbers channels backwards from URT */
153  bank_switch( fildes, 2-j, 0 );
154  dcblock_write( fildes, x_off, y_off - i,
155  x_len, 1, scan[j], 0 );
156  }
157 
158  /* KLUDGE for black and white. */
159  while (j <= RLE_BLUE)
160  {
161  bank_switch( fildes, 2-j, 1 );
162  dcblock_write( fildes, x_off, y_off - i,
163  x_len, 1, scan[0], 0 );
164  j++;
165  }
166  }
167 }
int xmin
Definition: rle.h:100
int scanargs(int argc, char **argv, const char *format,...)
Definition: scanargs.c:94
int rle_row_alloc(rle_hdr *the_hdr, rle_pixel ***scanp)
Definition: rle_row_alc.c:56
int driver_flag
Definition: getren.c:20
int display_flag
Definition: getren.c:19
#define RASTERHEIGHT
Definition: getren.c:24
#define FALSE
Definition: giftorle.c:39
rle_map * cmap
Definition: rle.h:112
rle_hdr hdr
Definition: iristorle.c:35
int ymin
Definition: rle.h:100
#define RLE_BLUE
Definition: rle.h:64
unsigned char ** scan
Definition: rle.c:26
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
#define RLE_RED
Definition: rle.h:62
int xmax
Definition: rle.h:100
int ncmap
Definition: rle.h:100
int ymax
Definition: rle.h:100
int cmaplen
Definition: rle.h:100
int i
Definition: rletorla.c:82
FILE * rle_open_f(const char *prog_name, const char *f_name, const char *mode)
char * driver_name
Definition: getren.c:22
#define MIN(a, b)
Definition: getren.c:14
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[])
char * display_name
Definition: getren.c:21
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

Variable Documentation

int display_flag = FALSE

Definition at line 19 of file getren.c.

char* display_name = "/dev/crt"

Definition at line 21 of file getren.c.

int driver_flag = FALSE

Definition at line 20 of file getren.c.

char* driver_name = "hp98721"

Definition at line 22 of file getren.c.