36 extern void *malloc();
38 extern char *malloc();
44 #define map_pixel( pix, cmaplen, cmap ) ((pix) > cmaplen ? (pix) :
71 char * infname = NULL, * outfname = NULL;
72 FILE *outfile = stdout;
73 int oflag = 0, y, nskip, nrow, one_to_many = 0, lflag = 0;
75 rle_hdr in_hdr, out_hdr;
76 rle_op ** scan, ** outscan;
79 rle_map ** cmap = NULL, *linmap = NULL, *mapp;
81 if (
scanargs( argc
, argv
, "% l%- o%-outfile!s infile%s",
82 &lflag
, &oflag
, &outfname
, &infname
) == 0 )
108 for ( c = 0; c < in_hdr
.ncmap; c++ )
109 cmap[c] = &in_hdr
.cmap[c * cmaplen];
121 for ( i = 1; i < out_hdr
.ncolors; i++ )
133 out_hdr
.cmap = linmap;
134 for ( c = 0, mapp = linmap; c < out_hdr
.ncolors; c++ )
135 for ( i = 0; i < cmaplen; i++ )
136 *mapp++ = i << (16 - in_hdr
.cmaplen);
146 sizeof( rle_op * ) );
150 scan[i] = (rle_op *)malloc( (nrow / 3 + 1) *
sizeof( rle_op ) );
153 sizeof( rle_op * ) );
160 outscan[i] = (rle_op *)malloc( (nrow / 3 + 1) *
163 outscan[0] = scan[0];
169 for ( i = 0; i < out_hdr
.ncolors; i++ )
179 outscan[i] = scan[i];
181 for ( i = 0; i < out_hdr
.ncolors; i++ )
209 for ( c = 1; c < out_hdr
.ncolors; c++ )
212 for ( i = 0; i < nraw[0]; i++ )
219 outscan[c][i] = scan[0][i];
220 outscan[c][i].u.run_val =
229 outscan[c][i] = scan[0][i];
230 outscan[c][i].u.pixels =
233 for ( j = 0; j < outscan[c][i]
.length;
235 outscan[c][i].u.pixels[j] =
244 for ( c = 0; c < in_hdr
.ncolors; c++ )
246 for ( i = 0; i < nraw[c]; i++ )
250 scan[c][i].u.run_val =
255 for ( j = 0; j < scan[c][i]
.length;
257 scan[c][i].u.pixels[j] =
FILE * rle_open_f(char *prog_name, char *file_name, char *mode)
#define RLE_SET_BIT(glob, bit)
void rle_freeraw(rle_hdr *the_hdr, scanraw, nraw)
char * cmd_name(char **argv)
void main(int argc, char **argv)
int rle_get_setup(rle_hdr *the_hdr)
void rle_putraw(rle_op **scanraw, int *nraw, rle_hdr *the_hdr)
int rle_get_error(int code, const char *pgmname, const char *fname)
int scanargs(int argc, char **argv, const char *format,...)
void rle_puteof(rle_hdr *the_hdr)
void rle_addhist(argv, rle_hdr *in_hdr, rle_hdr *out_hdr)
void rle_skiprow(rle_hdr *the_hdr, int nrow)
void rle_put_setup(rle_hdr *the_hdr)
#define map_pixel(pix, cmaplen, cmap)
unsigned int rle_getraw(rle_hdr *the_hdr, scanraw, nraw)