29 static char rcsid[] =
"$Header: /l/spencer/src/urt/cnv/RCS/ppmtorle.c,v 3.0.1.4 1992/03/04 19:29:43 spencer Exp $";
37 #define NO_DECLARE_MALLOC
42 #define VPRINTF if (verbose || header) fprintf
57 void read_ppm_header()
59 ppm_readppminit(fp, &width, &height, &maxval, &format);
60 VPRINTF(stderr,
"Image type: 24 bit true color\n");
62 VPRINTF(stderr,
"Maxval: %d\n", maxval);
64 VPRINTF(stderr,
"Computing alpha channel...\n");
69 void write_rle_header()
93 register pixel *pixelrow, *pP;
98 pixelrow = ppm_allocrow(width);
102 for ( scan = 0; scan <
height; scan++ )
109 for (scan = 0; scan <
height; scan++) {
110 scanline = scanlines[
height - scan - 1];
111 ppm_readppmrow(fp, pixelrow, width, maxval, format);
112 for (x = 0, pP = pixelrow; x <
width; x++, pP++) {
113 scanline[
RLE_RED][x] = PPM_GETR(*pP);
115 scanline[
RLE_BLUE][x] = PPM_GETB(*pP);
126 for ( scan = 0; scan <
height; scan++ )
133 VPRINTF(stderr,
"Done -- write eof to RLE data.\n");
144 char *periodP, *ppmname = NULL, *outname = NULL;
145 static char filename[BUFSIZ];
151 "% v%- h%- a%- o%-outfile!s infile.ppm%s\n(\
152 \tConvert PPM file to URT RLE format.\n\
153 \t-a\tFake an alpha channel. Alpha=0 when input=0, 255 otherwise.\n\
154 \t-h\tPrint header of PGM file.\n\
155 \t-v\tVerbose mode.\n\
156 \tInput file name (if given) is forced to end in .ppm.)",
169 if (ppmname == NULL) {
170 strcpy(filename,
"stdin");
174 periodP = strrchr(ppmname,
'.');
175 strcpy(filename, ppmname);
177 if (strcmp(periodP,
".ppm"))
178 strcat(filename,
".ppm");
181 strcat(filename,
".ppm");
182 if (!(
fp = fopen(filename,
"r"))) {
183 fprintf(stderr,
"%s: Cannot open %s for reading.\n",
190 while ( (c = getc(
fp )) != EOF )
FILE * rle_open_f(char *prog_name, char *file_name, char *mode)
#define RLE_SET_BIT(glob, bit)
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_row_alloc(rle_hdr *the_hdr, rle_pixel ***scanp)
int scanargs(int argc, char **argv, const char *format,...)
void rle_puteof(rle_hdr *the_hdr)
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)
#define RLE_CHECK_ALLOC(pgm, ptr, name)