52 char *outfname = NULL,
59 if (
scanargs( argc
, argv
, "% o%-outfile.gif!s infile.rle%s",
60 &oflag
, &outfname
, &infname
) == 0 )
71 if (
in_hdr.ncolors > 1) error(
"Input file should have only 1 channel.");
81 for ( i = 0; i < (1 << color_bits); i++ )
109 error(
"rle pixel size not 8 bits");
111 error(
"can't allocate scan");
112 save_scan_0 =
scan[0];
116 error(
"can't allocate scanbuf");
120 error(
"can't allocate current scanline");
124 scan[0] = save_scan_0;
134 int get_color_bits(comments)
137 int i, color_bits, num_colors;
140 if (comments == NULL)
return (color_bits);
141 for (i = 0; comments[i]; i++) {
142 if (!strncmp(comments[i],
"color_map_length=",17)) {
143 num_colors = atoi(&(comments[i][17]));
144 for (color_bits = 1; num_colors >> color_bits; color_bits++);
145 if (num_colors == (1<<(color_bits-1))) color_bits--;
149 if ((color_bits < 0) || (color_bits > 8))
150 error(
"invalid number of color bits");
163 fprintf(stderr,
"%s\n", s);
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)
void rle_row_free(rle_hdr *the_hdr, rle_pixel **scanp)
char * cmd_name(char **argv)
void main(int argc, char **argv)
int rle_row_alloc(rle_hdr *the_hdr, rle_pixel ***scanp)
int rle_getrow(rle_hdr *the_hdr, scanline)
static gif_pixel ** scanbuf
int scanargs(int argc, char **argv, const char *format,...)
void rle_get_setup_ok(rle_hdr *the_hdr, const char *prog_name, const char *file_name)
rle_hdr * rle_hdr_init(rle_hdr *the_hdr)