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

Go to the source code of this file.

Functions

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

Variables

short sbuf [4096]
 
rle_hdr hdr
 

Function Documentation

ctos ( unsigned char *  cptr,
unsigned short *  sptr,
int  n 
)

Definition at line 92 of file rletoiris.c.

96 {
97  while(n--) {
98  if(n>=8) {
99  sptr[0] = cptr[0];
100  sptr[1] = cptr[1];
101  sptr[2] = cptr[2];
102  sptr[3] = cptr[3];
103  sptr[4] = cptr[4];
104  sptr[5] = cptr[5];
105  sptr[6] = cptr[6];
106  sptr[7] = cptr[7];
107  sptr+=8;
108  cptr+=8;
109  n -= 7;
110  } else {
111  *sptr++ = *cptr++;
112  }
113  }
114 }
main ( int  argc,
argv   
)

Definition at line 35 of file rletoiris.c.

38 {
39  unsigned char *rows[3];
40  int i, y, xsize, ysize;
41  IMAGE *oimage;
42  FILE *infile;
43  char *infname = NULL, *outfname = NULL;
44 
45 /* get args */
46  if ( scanargs( argc, argv, "% o!-outimage.rgb!s in.rle%s\n(\
47 Convert URT RLE image in in.rle to SGI image format in outimage.rgb.\n\
48 Must specify -o outimage.rgb.)",
49  &i, &outfname, &infname ) == 0 )
50  exit( 1 );
51 
52 /* open the input file */
53  hdr = *rle_hdr_init( (rle_hdr *)NULL );
54  hdr.rle_file = rle_open_f(cmd_name(argv), infname, "r");
55  rle_names( &hdr, cmd_name(argv), infname, 0 );
56 
57  rle_get_setup_ok(&hdr, cmd_name(argv), infname);
58 
60  if(hdr.ncolors != 3) {
61  fprintf(stderr,"%s: input image must have 3 channels\n", hdr.cmd);
62  exit(1);
63  }
64 /* get the size */
65  xsize = hdr.xmax-hdr.xmin+1;
66  ysize = hdr.ymax-hdr.ymin+1;
67 
68 /* open the output file */
69  oimage = iopen(outfname,"w",RLE(1),3,xsize,ysize,3);
70 
71 /* allocate row buffers */
72  rows[0] = (unsigned char*)malloc(xsize);
73  rows[1] = (unsigned char*)malloc(xsize);
74  rows[2] = (unsigned char*)malloc(xsize);
75 
76 /* copy the image data */
77  for(y=0; y<ysize; y++) {
78  rle_getrow( &hdr, rows );
79  ctos(rows[0],sbuf,xsize);
80  putrow(oimage,sbuf,y,0);
81  ctos(rows[1],sbuf,xsize);
82  putrow(oimage,sbuf,y,1);
83  ctos(rows[2],sbuf,xsize);
84  putrow(oimage,sbuf,y,2);
85  }
86 
87 /* close the output file */
88  iclose(oimage);
89  exit(0);
90 }
int xmin
Definition: rle.h:100
int scanargs(int argc, char **argv, const char *format,...)
Definition: scanargs.c:94
rle_hdr hdr
Definition: rletoiris.c:33
int xsize
Definition: read98721.c:58
int ymin
Definition: rle.h:100
short sbuf[4096]
Definition: rletoiris.c:31
static int y
Definition: getami.c:691
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
int xmax
Definition: rle.h:100
Definition: RLE.h:13
rle_pixel ** rows
Definition: rletopaint.c:57
#define RLE_CLR_BIT(glob, bit)
Definition: rle.h:124
FILE * infile
Definition: targatorle.c:102
int ymax
Definition: rle.h:100
int ysize
Definition: read98721.c:59
void * malloc()
int i
Definition: rletorla.c:82
#define RLE_ALPHA
Definition: rle.h:65
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
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[])
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
ctos(unsigned char *cptr, unsigned short *sptr, int n)
Definition: rletoiris.c:92

Variable Documentation

rle_hdr hdr

Definition at line 33 of file rletoiris.c.

short sbuf[4096]

Definition at line 31 of file rletoiris.c.