29 static char rcsid[] =
"$Header: /l/spencer/src/urt/cnv/RCS/pgmtorle.c,v 3.0.1.5 1992/04/30 13:57:29 spencer Exp $";
40 #define NO_DECLARE_MALLOC
43 #define VPRINTF if (verbose || header) fprintf
59 void read_pgm_header()
61 pgm_readpgminit(fp, &width, &height, &maxval, &format);
62 VPRINTF(stderr,
"Image type: 8 bit grayscale\n");
64 VPRINTF(stderr,
"Maxval: %d\n", maxval);
66 VPRINTF(stderr,
"Computing alpha channel...\n");
71 void write_rle_header()
93 register gray *grayrow, *gP;
98 grayrow = pgm_allocrow(width);
102 for ( scan = 0; scan <
height; scan++ )
110 for (scan = 0; scan <
height; scan++) {
111 pgm_readpgmrow(fp, grayrow, width, maxval, format);
112 scanline = scanlines[
height - scan - 1];
113 for (x = 0, gP = grayrow; x <
width; x++, gP++) {
116 scanline[
RLE_ALPHA][x] = (*gP ? 255 : 0);
122 for ( scan = 0; scan <
height; scan++ )
128 VPRINTF(stderr,
"Done -- write eof to RLE data.\n");
143 char *periodP, *pgmname = 0, *outname = 0;
144 static char filename[BUFSIZ];
149 "% v%- h%- a%- o%-outfile!s infile.pgm%s\n(\
150 \tConvert a PGM file to URT RLE format.\n\
151 \t-a\tFake an alpha channel. Alpha=0 when input=0, 255 otherwise.\n\
152 \t-h\tPrint header of PGM file.\n\
153 \t-v\tVerbose mode.\n\
154 \tInput file name is forced to end in .pgm.)",
167 if (pgmname == NULL) {
168 strcpy(filename,
"stdin");
172 periodP = strrchr(pgmname,
'.');
173 strcpy(filename, pgmname);
175 if (strcmp(periodP,
".pgm"))
176 strcat(filename,
".pgm");
179 strcat(filename,
".pgm");
180 if (!(
fp = fopen(filename,
"r"))) {
181 fprintf(stderr,
"%s: Cannot open %s for reading.\n",
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)