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

Go to the source code of this file.

Functions

 main (int argc, char **argv)
 
 stoc (unsigned short *sptr, unsigned char *cptr, int n)
 

Variables

short rbuf [8192]
 
short gbuf [8192]
 
short bbuf [8192]
 
rle_hdr hdr
 

Function Documentation

main ( int  argc,
char **  argv 
)

Definition at line 37 of file iristorle.c.

40 {
41  IMAGE *image;
42  int i, y, z;
43  int xsize, ysize, zsize;
44  unsigned char *rows[3];
45  char *infname = NULL, *outfname = NULL;
46 
47  if ( scanargs( argc, argv, "% o%-outfile.rle!s, infile.rgb!s\n\
48 (Convert SGI image in infile.rgb to URT RLE image in outfile.rle.)",
49  &i, &outfname, &infname ) == 0 )
50  exit( 1 );
51 
52 /* open the input file */
53  image=iopen(infname,"r");
54  if(!image) {
55  fprintf(stderr,"%s: can't open input file %s\n",cmd_name(argv),infname);
56  exit(1);
57  }
58  xsize = image->xsize;
59  ysize = image->ysize;
60  zsize = image->zsize;
61 
62 /* open the output file */
63  hdr = *rle_hdr_init( NULL );
64  rle_names( &hdr, cmd_name( argv ), outfname, 0 );
65  rle_addhist( argv, (rle_hdr *)NULL, &hdr );
66  hdr.rle_file = rle_open_f(hdr.cmd,outfname,"w");
67 
68 /* allocate row buffers */
69  rows[0] = (unsigned char *)malloc(xsize*sizeof(unsigned char));
70  rows[1] = (unsigned char *)malloc(xsize*sizeof(unsigned char));
71  rows[2] = (unsigned char *)malloc(xsize*sizeof(unsigned char));
72 
73 /* set up the header */
74  hdr.xmin = 0;
75  hdr.xmax = xsize - 1;
76  hdr.ymin = 0;
77  hdr.ymax = ysize - 1;
78  hdr.ncolors = 3;
79  hdr.background = 0;
80  hdr.alpha = 0;
81  hdr.ncmap = 0;
86 
87 /* copy image data */
88  for(y=0; y<ysize; y++) {
89  if(image->zsize<3) {
90  getrow(image,rbuf,y,0);
91  stoc(rbuf,rows[0],xsize);
92  stoc(rbuf,rows[1],xsize);
93  stoc(rbuf,rows[2],xsize);
94  } else {
95  getrow(image,rbuf,y,0);
96  getrow(image,gbuf,y,1);
97  getrow(image,bbuf,y,2);
98  stoc(rbuf,rows[0],xsize);
99  stoc(gbuf,rows[1],xsize);
100  stoc(bbuf,rows[2],xsize);
101  }
102  rle_putrow(rows,xsize,&hdr);
103  }
104 
105 /* close the output file */
106  rle_puteof(&hdr);
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
void rle_putrow(rle_pixel *rows[], int rowlen, rle_hdr *the_hdr)
#define RLE_GREEN
Definition: rle.h:63
void rle_addhist(char *argv[], rle_hdr *in_hdr, rle_hdr *out_hdr)
int xsize
Definition: read98721.c:58
rle_hdr hdr
Definition: iristorle.c:35
int ymin
Definition: rle.h:100
#define RLE_BLUE
Definition: rle.h:64
void rle_puteof(rle_hdr *the_hdr)
Definition: rle_putrow.c:474
static int y
Definition: getami.c:691
stoc(unsigned short *sptr, unsigned char *cptr, int n)
Definition: iristorle.c:110
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
Definition: rle.h:96
#define RLE_RED
Definition: rle.h:62
int xmax
Definition: rle.h:100
rle_pixel ** rows
Definition: rletopaint.c:57
int background
Definition: rle.h:100
int ncmap
Definition: rle.h:100
int ymax
Definition: rle.h:100
int ysize
Definition: read98721.c:59
Colorindex * image
Definition: getmex.c:29
void * malloc()
int i
Definition: rletorla.c:82
short bbuf[8192]
Definition: iristorle.c:33
int alpha
Definition: rle.h:100
FILE * rle_open_f(const char *prog_name, const char *f_name, const char *mode)
short rbuf[8192]
Definition: iristorle.c:31
void rle_put_setup(rle_hdr *the_hdr)
Definition: rle_putrow.c:453
char * cmd_name(char **argv)
Definition: cmd_name.c:31
short gbuf[8192]
Definition: iristorle.c:32
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
stoc ( unsigned short *  sptr,
unsigned char *  cptr,
int  n 
)

Definition at line 110 of file iristorle.c.

114 {
115  while(n--) {
116  if(n>=8) {
117  cptr[0] = sptr[0];
118  cptr[1] = sptr[1];
119  cptr[2] = sptr[2];
120  cptr[3] = sptr[3];
121  cptr[4] = sptr[4];
122  cptr[5] = sptr[5];
123  cptr[6] = sptr[6];
124  cptr[7] = sptr[7];
125  sptr+=8;
126  cptr+=8;
127  n -= 7;
128  } else {
129  *cptr++ = *sptr++;
130  }
131  }
132 }

Variable Documentation

short bbuf[8192]

Definition at line 33 of file iristorle.c.

short gbuf[8192]

Definition at line 32 of file iristorle.c.

rle_hdr hdr

Definition at line 35 of file iristorle.c.

short rbuf[8192]

Definition at line 31 of file iristorle.c.