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

Go to the source code of this file.

Macros

#define TRUE   1
 
#define FALSE   0
 
#define MAX(i, j)    ((i) > (j) ? (i) : (j))
 
#define NCHANS   3
 
#define NCMAPS   3
 
#define CMAPLEN   8
 
#define COLMAPLEN   256
 
#define MAX_X_SIZE   1280
 
#define D_XSTART   0
 
#define D_YSTART   0
 
#define D_XSIZE   512
 
#define D_YSIZE   480
 

Functions

 main (int argc, argv)
 
 setup_graphics_device (int *dev_xmax, int *dev_ymax)
 
 clip (int dev_xmax, int dev_ymax, int *xstart, int *ystart, int *xsize, int *ysize)
 
 read_scanline (rle_hdr *the_hdr, int y, rows)
 
 read_color_maps (int pic_fd, rle_map *cmap)
 

Variables

int cmap_flag = 0
 
int display_flag = 0
 
int driver_flag = 0
 
char * display_name = "/dev/crt"
 
char * driver_name = "hp98721"
 
int pos_flag = 0
 
int xstart = 0
 
int ystart = 0
 
int size_flag = 0
 
int xsize = 512
 
int ysize = 480
 
int overlay_flag = 0
 
int backgnd_flag = 0
 
int backgnd [3]
 
int fname_flag = 0
 
char * fname = ((void *)0)
 
int ncomments = 0
 
char ** comments = ((void *)0)
 
int picture_fd
 

Macro Definition Documentation

#define CMAPLEN   8

Definition at line 31 of file read98721.c.

#define COLMAPLEN   256

Definition at line 32 of file read98721.c.

#define D_XSIZE   512

Definition at line 56 of file read98721.c.

#define D_XSTART   0

Definition at line 48 of file read98721.c.

#define D_YSIZE   480

Definition at line 57 of file read98721.c.

#define D_YSTART   0

Definition at line 49 of file read98721.c.

#define FALSE   0

Definition at line 26 of file read98721.c.

#define MAX (   i,
 
)    ((i) > (j) ? (i) : (j))

Definition at line 27 of file read98721.c.

#define MAX_X_SIZE   1280

Definition at line 33 of file read98721.c.

#define NCHANS   3

Definition at line 29 of file read98721.c.

#define NCMAPS   3

Definition at line 30 of file read98721.c.

#define TRUE   1

Definition at line 25 of file read98721.c.

Function Documentation

clip ( int  dev_xmax,
int  dev_ymax,
int xstart,
int ystart,
int xsize,
int ysize 
)

Definition at line 203 of file read98721.c.

205 {
206  if(*xstart < 0) {
207  *xsize += *xstart;
208  *xstart = 0;
209  }
210  if(*ystart < 0) {
211  *ysize += *ystart;
212  *ystart = 0;
213  }
214  if(*xstart + *xsize > dev_xmax)
215  *xsize = dev_xmax - *xstart;
216  if(*ystart + *ysize > dev_ymax)
217  *ysize = dev_ymax - *ystart;
218 }
int xsize
Definition: read98721.c:58
int ystart
Definition: read98721.c:51
int xstart
Definition: read98721.c:50
int ysize
Definition: read98721.c:59
main ( int  argc,
argv   
)

Definition at line 79 of file read98721.c.

82 {
83  int i,y;
84  int dev_xmax,dev_ymax;
87  unsigned char scanline[NCHANS][MAX_X_SIZE],*rows[NCHANS]; /* Scanline storage & RLE row pointers */
88 
89  if (scanargs(argc, argv,
90  "% m%- O%- d%-display!s x%-driver!s p%-xstart!dystart!d s%-xsize!dysize!d \
91  b%-rbak!dgbak!dbbak!d o%-fname!s comments%*s",
92  &cmap_flag,
93  &overlay_flag,
98  &backgnd_flag,&(backgnd[0]),&(backgnd[1]),&(backgnd[2]),
99  &fname_flag,&fname,
100  &ncomments,&comments) == 0)
101  exit(1);
102 
103  the_hdr = *rle_hdr_init( (rle_hdr *)NULL );
104  rle_names( &the_hdr, cmd_name( argv ), fname, 0 );
105 
106  if(overlay_flag && backgnd_flag) {
107  fprintf(stderr,"read98721: incompatible options -O and -b\n");
108  exit(1);
109  }
110 
111  /* initialize the display device */
112  setup_graphics_device(&dev_xmax,&dev_ymax);
113 
114  clip(dev_xmax,dev_ymax,&xstart,&ystart,&xsize,&ysize);
115  if((xsize <= 0)||(ysize <= 0)) {
116  fprintf(stderr,"%s: null image size\n", the_hdr.cmd);
117  exit(1);
118  }
119 
120  /* open output file */
121  the_hdr.rle_file = rle_open_f(the_hdr.cmd, fname, "w");
122  /* initialize image header */
123  the_hdr.ncolors = NCHANS;
124  the_hdr.bg_color = backgnd_flag ? backgnd : (int *)0;
125  the_hdr.alpha = FALSE;
126  the_hdr.background = backgnd_flag ? 2 : (overlay_flag ? 1 : 0);
127  the_hdr.xmin = xstart;
128  the_hdr.xmax = xstart + xsize -1;
129  the_hdr.ymin = ystart;
130  the_hdr.ymax = ystart + ysize -1;
131  if(cmap_flag) {
133  the_hdr.ncmap = NCMAPS;
134  the_hdr.cmaplen = CMAPLEN;
135  the_hdr.cmap = cmap;
136  } else {
137  the_hdr.ncmap = 0;
138  the_hdr.cmaplen = 0;
139  the_hdr.cmap = (rle_map *)0;
140  }
141  the_hdr.bits[0] = 0x07;
142  for(i=0; i<ncomments; i++)
143  rle_putcom(comments[i],&the_hdr);
144 
145  rle_addhist( argv, (rle_hdr *)NULL, &the_hdr );
146  rle_put_setup(&the_hdr);
147 
148  /* set up rows to point to our copy of the scanline */
149  for (i= 0; i<NCHANS; i++)
150  rows[i] = scanline[i];
151 
152  /* save image */
153  for(y=the_hdr.ymin; y<=the_hdr.ymax; y++) {
154  read_scanline(y,rows);
155  rle_putrow(rows,xsize,&the_hdr);
156  }
157 
158  rle_puteof(&the_hdr);
159 
160  exit(0);
161 }
int pos_flag
Definition: read98721.c:45
rle_hdr the_hdr
Definition: aliastorle.c:100
int cmap_flag
Definition: read98721.c:36
int xmin
Definition: rle.h:100
int scanargs(int argc, char **argv, const char *format,...)
Definition: scanargs.c:94
#define MAX_X_SIZE
Definition: read98721.c:33
int ncomments
Definition: read98721.c:73
const char * rle_putcom(const char *value, rle_hdr *the_hdr)
rle_map * cmap
Definition: rle.h:112
void rle_putrow(rle_pixel *rows[], int rowlen, rle_hdr *the_hdr)
int * bg_color
Definition: rle.h:100
void rle_addhist(char *argv[], rle_hdr *in_hdr, rle_hdr *out_hdr)
int xsize
Definition: read98721.c:58
int ymin
Definition: rle.h:100
int ystart
Definition: read98721.c:51
void rle_puteof(rle_hdr *the_hdr)
Definition: rle_putrow.c:474
static int y
Definition: getami.c:691
int xstart
Definition: read98721.c:50
#define NCMAPS
Definition: read98721.c:30
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 backgnd_flag
Definition: read98721.c:64
int xmax
Definition: rle.h:100
int size_flag
Definition: read98721.c:53
char * driver_name
Definition: read98721.c:43
int display_flag
Definition: read98721.c:38
int backgnd[3]
Definition: read98721.c:66
rle_pixel ** rows
Definition: rletopaint.c:57
char bits[256/8]
Definition: rle.h:128
int fname_flag
Definition: read98721.c:68
#define CMAPLEN
Definition: read98721.c:31
clip(int dev_xmax, int dev_ymax, int *xstart, int *ystart, int *xsize, int *ysize)
Definition: read98721.c:203
int background
Definition: rle.h:100
read_color_maps(int pic_fd, rle_map *cmap)
Definition: read98721.c:236
char * display_name
Definition: read98721.c:42
int ncmap
Definition: rle.h:100
int ymax
Definition: rle.h:100
#define NCHANS
Definition: read98721.c:29
int ysize
Definition: read98721.c:59
char ** comments
Definition: read98721.c:74
int cmaplen
Definition: rle.h:100
int i
Definition: rletorla.c:82
int alpha
Definition: rle.h:100
read_scanline(rle_hdr *the_hdr, int y, rows)
Definition: read98721.c:221
int picture_fd
Definition: read98721.c:77
FILE * rle_open_f(const char *prog_name, const char *f_name, const char *mode)
#define COLMAPLEN
Definition: read98721.c:32
void rle_put_setup(rle_hdr *the_hdr)
Definition: rle_putrow.c:453
unsigned short rle_map
Definition: rle.h:57
char * cmd_name(char **argv)
Definition: cmd_name.c:31
unsigned char scanline[4][1280]
Definition: get_orion.c:37
rle_pixel ** cmap
Definition: get4d.c:47
int driver_flag
Definition: read98721.c:39
#define FALSE
Definition: read98721.c:26
int overlay_flag
Definition: read98721.c:61
FILE * rle_file
Definition: rle.h:114
int ncolors
Definition: rle.h:100
char * fname
Definition: read98721.c:71
setup_graphics_device(int *dev_xmax, int *dev_ymax)
Definition: read98721.c:164
rle_hdr * rle_hdr_init(rle_hdr *the_hdr)
Definition: rle_hdr.c:267
read_color_maps ( int  pic_fd,
rle_map cmap 
)

Definition at line 236 of file read98721.c.

239 {
240  int i,cmaplen;
241  rle_map *rmap,*gmap,*bmap;
242  float colmap[COLMAPLEN][NCMAPS];
243 
244  inquire_color_table(pic_fd,0,COLMAPLEN,colmap);
245  rmap = cmap;
246  gmap = cmap + COLMAPLEN;
247  bmap = cmap + COLMAPLEN * 2;
248  for(i=0; i<COLMAPLEN; i++) {
249  rmap[i] = colmap[i][2];
250  gmap[i] = colmap[i][1];
251  bmap[i] = colmap[i][0];
252  }
253 }
rle_pixel ** rmap
Definition: rlestereo.c:58
#define NCMAPS
Definition: read98721.c:30
short colmap[128][3]
Definition: get4d.c:37
int i
Definition: rletorla.c:82
#define COLMAPLEN
Definition: read98721.c:32
unsigned short rle_map
Definition: rle.h:57
rle_pixel ** cmap
Definition: get4d.c:47
read_scanline ( rle_hdr the_hdr,
int  y,
rows   
)

Definition at line 221 of file read98721.c.

225 {
226  int i,j;
227 
228  for(i=0,j=NCHANS-1; i<NCHANS; i++,j--) {
229  bank_switch(picture_fd,j,0);
230  block_read(picture_fd,(float)(the_hdr->xmin),(float)y,
231  the_hdr->xmax - the_hdr->xmin + 1,1,rows[i],FALSE);
232  }
233 }
int xmin
Definition: rle.h:100
static int y
Definition: getami.c:691
int xmax
Definition: rle.h:100
rle_pixel ** rows
Definition: rletopaint.c:57
#define NCHANS
Definition: read98721.c:29
int i
Definition: rletorla.c:82
int picture_fd
Definition: read98721.c:77
#define FALSE
Definition: read98721.c:26
setup_graphics_device ( int dev_xmax,
int dev_ymax 
)

Definition at line 164 of file read98721.c.

166 {
167  float p_lim[2][3],res[3],p1[3],p2[3];
168  int map_size;
169 
170  picture_fd = gopen(display_name,OUTDEV,driver_name,0);
171  if(picture_fd < 0) {
172  fprintf(stderr,"read98721: can't open device.\n");
173  exit(1);
174  }
175  shade_mode(picture_fd,CMAP_FULL,FALSE);
176 
177  /* find out info about this device. */
178  inquire_sizes(picture_fd,p_lim,res,p1,p2,&map_size);
179 
180  /* set the screen limits in pixels so we can use starbase in a device
181  * independent way.
182  *
183  * it is assumed that the p_lim values returned by inquire_sizes are the
184  * lower left screen coordinates in (float) pixels and the upper right
185  * screen coordinates in (float) pixels. It is also assumed that the
186  * range of values in x and y coordinates are given from 0 to some
187  * positive maximum value.
188  */
189  *dev_xmax = MAX(p_lim[0][0],p_lim[1][0]) + 1.0;
190  *dev_ymax = MAX(p_lim[0][1],p_lim[1][1]) + 1.0;
191 
192  /* set to use the whole display surface. */
193  mapping_mode(picture_fd,DISTORT);
194 
195  /* set to address the pixels in a device independent way. */
196  vdc_extent(picture_fd,0.0,0.0,0.0,(float)(*dev_xmax)-1.0,
197  (float)(*dev_ymax)-1.0,0.0);
198  clip_rectangle(picture_fd,0.0,(float)(*dev_xmax)-1.0,
199  0.0,(float)(*dev_ymax)-1.0);
200 }
#define MAX(i, j)
Definition: read98721.c:27
char * driver_name
Definition: read98721.c:43
char * display_name
Definition: read98721.c:42
int picture_fd
Definition: read98721.c:77
#define FALSE
Definition: read98721.c:26

Variable Documentation

int backgnd[3]

Definition at line 66 of file read98721.c.

int backgnd_flag = 0

Definition at line 64 of file read98721.c.

int cmap_flag = 0

Definition at line 36 of file read98721.c.

char** comments = ((void *)0)

Definition at line 74 of file read98721.c.

int display_flag = 0

Definition at line 38 of file read98721.c.

char* display_name = "/dev/crt"

Definition at line 42 of file read98721.c.

int driver_flag = 0

Definition at line 39 of file read98721.c.

char* driver_name = "hp98721"

Definition at line 43 of file read98721.c.

char* fname = ((void *)0)

Definition at line 71 of file read98721.c.

Referenced by Fail(), and main().

int fname_flag = 0

Definition at line 68 of file read98721.c.

int ncomments = 0

Definition at line 73 of file read98721.c.

int overlay_flag = 0

Definition at line 61 of file read98721.c.

int picture_fd

Definition at line 77 of file read98721.c.

Referenced by direct_setup().

int pos_flag = 0

Definition at line 45 of file read98721.c.

int size_flag = 0

Definition at line 53 of file read98721.c.

int xsize = 512

Definition at line 58 of file read98721.c.

int xstart = 0

Definition at line 50 of file read98721.c.

int ysize = 480

Definition at line 59 of file read98721.c.

int ystart = 0

Definition at line 51 of file read98721.c.