50 static char rcs_ident[] =
"$Id: rletops.c,v 3.0.1.2 1992/01/20 18:04:10 spencer Exp $";
57 void prologue(), puthexpix(), epilogue();
73 int add_extra_white_line = 0;
74 float heightinch = 3.0,
77 int y, nrow, nscan, i, pix, dummy;
78 float x1, y1, x2, y2, widthinch;
79 unsigned char ** scan;
80 unsigned char * buffer;
83 "% C%- s%- h%-height!f c%-center!f a%-aspect!f o%-outfile!s infile%s\n(\
84 \tConvert a URT RLE image to PostScript.\n\
85 \t-C\tOutput color PostScript.\n\
86 \t-s\t\"Scribe mode\", no showpage, center about 3.25\" at bottom.\n\
87 \t-h\tScale output to given height in inches.\n\
88 \t-c\tCenter at given distance from left (default 3.25\").\n\
89 \t-a\tPixel aspect ratio (default 1.0).)",
90 &
gencps, &sflag
, &dummy
, &heightinch
, &cflag
, ¢er
, &dummy
,
91 &aspect
, &oflag
, &outfname
, &infname
) == 0 )
104 fprintf( stderr,
"%s is not RGB or b&w image",
105 infname ? infname :
"stdin" );
127 add_extra_white_line = 1;
132 buffer = (
unsigned char *)malloc( nrow );
137 widthinch = (
float) nrow * heightinch * aspect / (
float) nscan;
140 x1 = center - widthinch / 2.0;
146 x1 = center - widthinch / 2.0;
149 x1 = 4.25 - widthinch / 2.0;
151 y1 = 11.0 - 1.0 - heightinch;
154 y2 = y1 + heightinch;
155 prologue(outfile,sflag,nscan,nrow,x1,y1,x2,y2);
162 for(pix = 0; pix < nrow; pix ++) {
163 puthexpix(outfile,scan[0][pix]);
164 puthexpix(outfile,scan[1][pix]);
165 puthexpix(outfile,scan[2][pix]);
173 for(pix = 0; pix < nrow; pix ++)
174 puthexpix(outfile,buffer[pix]);
177 if (add_extra_white_line)
178 for(i = 0; i < (
gencps ? 3 : 1); i++)
179 for(pix = 0; pix < nrow; pix ++)
180 puthexpix(outfile,255);
182 epilogue(outfile, sflag);
188 prologue(outfile,scribe_mode,nr,nc,x1,y1,x2,y2)
194 fprintf(outfile,
"%%!\n");
195 fprintf(outfile,
"%%%%BoundingBox: %d %d %d %d\n",
196 (
int)(x1 * 72), (
int)(y1 * 72),
197 (
int)(x2 * 72), (
int)(y2 * 72));
198 fprintf(outfile,
"%%%%EndComments\n");
199 fprintf(outfile,
"gsave\n");
201 fprintf(outfile,
"initgraphics\n");
202 fprintf(outfile,
"72 72 scale\n");
203 fprintf(outfile,
"/imline %d string def\n",nc*2*(
gencps?3:1));
204 fprintf(outfile,
"/drawimage {\n");
205 fprintf(outfile,
" %d %d 8\n",nc,nr);
206 fprintf(outfile,
" [%d 0 0 %d 0 %d]\n",nc,-1*nr,nr);
207 fprintf(outfile,
" { currentfile imline readhexstring pop } ");
209 fprintf(outfile,
"false 3 colorimage\n");
211 fprintf(outfile,
"image\n");
212 fprintf(outfile,
"} def\n");
213 fprintf(outfile,
"%f %f translate\n",x1,y2);
214 fprintf(outfile,
"%f %f scale\n",x2-x1,y1-y2);
215 fprintf(outfile,
"drawimage\n");
219 epilogue(outfile, scribemode)
223 fprintf(outfile,
"\n");
225 fprintf(outfile,
"showpage\n");
226 fprintf(outfile,
"grestore\n");
235 static char tohex[] =
"0123456789ABCDEF";
237 putc(tohex[(p>>4)&0xF],outfile);
238 putc(tohex[p&0xF],outfile);
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)
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)
void rgb_to_bw(rle_pixel *red_row, rle_pixel *green_row, rle_pixel *blue_row, rle_pixel *bw_row, int rowlen)
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)