29 static char rcsid[] =
"$Header: /l/spencer/src/urt/cnv/RCS/rletoppm.c,v 3.0.1.4 1992/03/04 19:30:10 spencer Exp $";
38 #define NO_DECLARE_MALLOC
43 #define VPRINTF if (verbose || header) fprintf
45 #define PSEUDOCOLOR 010
47 #define DIRECTCOLOR 100
68 void read_rle_header()
80 VPRINTF(stderr,
"Mapped color image with a map of length %d.\n",
maplen);
84 VPRINTF(stderr,
"24 bit color image, no colormap.\n");
90 VPRINTF(stderr,
"24 bit color image with color map of length %d\n" ,
maplen);
94 VPRINTF(stderr,
"Grayscale image.\n");
98 "ncolors = %d, ncmap = %d, I don't know how to handle this!\n",
103 VPRINTF(stderr,
"No alpha channel.\n");
105 VPRINTF(stderr,
"Alpha channel exists!\n");
107 fprintf(stderr,
"alpha = %d, I don't know how to handle this!\n",
113 VPRINTF(stderr,
"Use all pixels, ignore background color.");
117 "Use only non-background pixels, ignore background color.");
121 "Use only non-background pixels, clear to background color (default).");
124 VPRINTF(stderr,
"Unknown background flag!\n");
130 VPRINTF(stderr,
" (%d %d %d)\n",
136 VPRINTF(stderr,
" (%d %d %d)\n",
150 void write_ppm_data()
153 register pixval r, g, b;
154 register pixel *pixelrow, *pP;
155 register int scan, x, y;
159 pixelrow = ppm_allocrow(width);
164 for ( scan = 0; scan <
height; scan++ )
170 for (scan = 0; scan <
height; scan++)
172 for (scan = 0; scan <
height; scan++) {
173 scanline = scanlines[scan];
176 for (x = 0, pP = pixelrow; x <
width; x++, pP++) {
180 PPM_ASSIGN(*pP, r, g, b);
184 for (x = 0, pP = pixelrow; x <
width; x++, pP++) {
185 r = colormap[scanline[0][x]]>>8;
186 g = colormap[scanline[1][x]+256]>>8;
187 b = colormap[scanline[2][x]+512]>>8;
188 PPM_ASSIGN(*pP, r, g, b);
192 for (x = 0, pP = pixelrow; x <
width; x++, pP++) {
196 PPM_ASSIGN(*pP, r, g, b);
200 for (x = 0, pP = pixelrow; x <
width; x++, pP++) {
201 r = colormap[scanline[0][x]]>>8;
202 g = colormap[scanline[0][x]+256]>>8;
203 b = colormap[scanline[0][x]+512]>>8;
204 PPM_ASSIGN(*pP, r, g, b);
213 ppm_writeppmrow(stdout, pixelrow, width, maxval, plain);
217 for ( scan = 0; scan <
height; scan++ )
234 "% v%- h%- p%- infile%s\n(\
235 \tConvert an RLE image to ppm true color.\n\
236 \t-v\tVerbose -- print out progress.\n\
237 \t-h\tPrint RLE header information and exit.\n\
238 \t-p\tWrite output image in \"plain\" mode.)",
261 ppm_writeppminit(stdout, width, height, maxval, plain);
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)
gpr_ $bmf_group_header_array_t header
void rle_row_free(rle_hdr *the_hdr, rle_pixel **scanp)
char * cmd_name(char **argv)
void main(int argc, char **argv)
int rle_get_setup(rle_hdr *the_hdr)
int rle_row_alloc(rle_hdr *the_hdr, rle_pixel ***scanp)
int rle_getrow(rle_hdr *the_hdr, scanline)
int scanargs(int argc, char **argv, const char *format,...)
rle_hdr * rle_hdr_init(rle_hdr *the_hdr)
#define RLE_CHECK_ALLOC(pgm, ptr, name)