92 "% b%-bg_color_comps%*d f%-fg_color_comps%*d o%-outfile!s infile.xbm%s\n(\
93 \tConvert an X bitmap file (NOT X window dump) to URT format.\n\
94 \t-b/-f\tSpecify color to use for background/foreground bits.\n\
95 \t\tFollowed by one or more color components. Number of\n\
96 \t\tcomponents must be the same for both -b and -f.\n\
97 \t\tDefaults are 0 and 255 respectively.)",
98 &bflag, &nbg, &bg, &fflag, &nfg, &fg,
99 &
oflag, &ofname, &infname ) == 0 )
105 if ( bflag && fflag && nbg != nfg )
108 "%s: Warning: Number of background color components (%d) not the same as\n\
109 the foreground (%d), using %d\n",
110 MY_NAME, nbg, nfg, nbg < nfg ? nbg : nfg );
118 if ( bflag & !fflag && nbg > 1 )
120 fg = (
int *)
malloc( nbg *
sizeof(
int) );
121 for ( nfg = 0; nfg < nbg; nfg++ )
124 if ( fflag & !bflag && nfg > 1 )
126 bg = (
int *)
malloc( nfg *
sizeof(
int) );
127 for ( nbg = 0; nbg < nfg; nbg++ )
133 if (
ReadBitmapFile( xbm_file, &width, &height, &bytes, &data ) == 0 )
142 out_hdr.
xmax = width - 1;
143 out_hdr.
ymax = height - 1;
153 for ( y = 0; y <
height; y++ )
157 register char *datap;
159 datap = data + (height - y - 1) * bytes;
160 for ( x = 0; x <
width; x++ )
162 if ( charcount >= 8 )
168 for ( c = 0; c < nbg; c++ )
169 scans[c][x] = ( *datap & mask ) ? fg[c] : bg[c];
int scanargs(int argc, char **argv, const char *format,...)
int rle_row_alloc(rle_hdr *the_hdr, rle_pixel ***scanp)
void rle_putrow(rle_pixel *rows[], int rowlen, rle_hdr *the_hdr)
void rle_addhist(char *argv[], rle_hdr *in_hdr, rle_hdr *out_hdr)
void rle_puteof(rle_hdr *the_hdr)
void rle_names(rle_hdr *the_hdr, const char *pgmname, const char *fname, int img_num)
static int ReadBitmapFile()
FILE * rle_open_f(const char *prog_name, const char *f_name, const char *mode)
void rle_put_setup(rle_hdr *the_hdr)
char * cmd_name(char **argv)
rle_hdr * rle_hdr_init(rle_hdr *the_hdr)