32 void read_cubi_hdr(), read_cubi_row(), read_cubi_chan(), bit_read();
43 int cubi_xlen, cubi_ylen;
44 char *infname = NULL, *outfname = NULL;
49 "% o%-outfile!s inprefix!s\n(\
50 \tConvert Cubicomp image to URT image. Input image is in 3 files,\n\
51 \tinprefix.r, inprefix.g, inprefix.b.)",
52 &oflag
, &outfname
, &infname
) == 0 )
58 for ( i = 0; i < 3; i++ )
60 sprintf( filename,
"%s.%c8", infname,
"rgb"[i] );
64 read_cubi_hdr(cubifiles, &cubi_xlen, &cubi_ylen);
79 fprintf( stderr,
"%s: malloc failed\n", hdr
.cmd );
85 read_cubi_row( cubifiles, rows );
92 read_cubi_hdr(cubifiles, xlen, ylen)
97 short xmin, ymin, xmax, ymax;
99 fread(junk,
sizeof(
char), 12, cubifiles[0]);
100 fread(xlen,
sizeof(
short), 1, cubifiles[0]);
101 fread(ylen,
sizeof(
short), 1, cubifiles[0]);
102 fread(&xmin,
sizeof(
short), 1, cubifiles[0]);
103 fread(&ymin,
sizeof(
short), 1, cubifiles[0]);
104 fread(&xmax,
sizeof(
short), 1, cubifiles[0]);
105 fread(&ymax,
sizeof(
short), 1, cubifiles[0]);
106 fread(junk,
sizeof(
char), 104, cubifiles[0]);
108 fread(junk,
sizeof(
char), 128, cubifiles[1]);
109 fread(junk,
sizeof(
char), 128, cubifiles[2]);
113 read_cubi_row(cubifiles, rows)
117 read_cubi_chan(cubifiles[0],rows,0);
118 read_cubi_chan(cubifiles[1],rows,1);
119 read_cubi_chan(cubifiles[2],rows,2);
123 read_cubi_chan(infile, rows, chan)
128 static char headchar[3];
129 static int scanfull[3] = {-1, -1, -1};
134 if (scanfull[chan] == -1)
135 headchar[chan] = fgetc(infile);
137 for (bit = 0; bit < 8; bit++)
138 if (scanfull[chan] <= bit)
140 bit_read(infile, headchar[chan], bit, rows, chan, &xpos);
143 scanfull[chan] = bit + 1;
147 if (bit >= 7) scanfull[chan] = -1;
152 bit_read(infile, headchar, bit, rows, chan, xpos)
155 int bit, chan, *xpos;
158 unsigned char runlength, rundata, bytedata;
161 if (headchar & (1 << bit))
164 rundata = fgetc(infile);
165 runlength = fgetc(infile);
166 for (i=(*xpos); i < runlength+(*xpos); i++)
167 rows[chan][i] = rundata;
168 *xpos += (
int) runlength;
173 bytedata = fgetc(infile);
174 rows[chan][*xpos] = bytedata;
FILE * rle_open_f(char *prog_name, char *file_name, char *mode)
void rle_names(rle_hdr *the_hdr, const char *pgmname, const char *fname, int img_num)
char * cmd_name(char **argv)
void main(int argc, char **argv)
int rle_row_alloc(rle_hdr *the_hdr, rle_pixel ***scanp)
int scanargs(int argc, char **argv, const char *format,...)
void rle_putrow(rows, int rowlen, rle_hdr *the_hdr)
void rle_addhist(argv, rle_hdr *in_hdr, rle_hdr *out_hdr)
void rle_put_setup(rle_hdr *the_hdr)
rle_hdr * rle_hdr_init(rle_hdr *the_hdr)