6 |
|
*/ |
7 |
|
|
8 |
|
#include <stdio.h> |
9 |
+ |
#include <string.h> |
10 |
|
#include <math.h> |
11 |
|
#include <ctype.h> |
12 |
|
|
13 |
|
#include "platform.h" |
14 |
|
#include "color.h" |
15 |
+ |
#include "resolu.h" |
16 |
|
|
17 |
|
#define UPPER(c) ((c)&~0x20) /* ASCII trick */ |
18 |
|
|
51 |
|
int bradj = 0; /* brightness adjustment */ |
52 |
|
int ncopies = 1; /* number of copies */ |
53 |
|
|
54 |
< |
extern int Aputprim(), Bputprim(), Cputprim(); |
54 |
> |
char *progname; |
55 |
> |
int xmax, ymax; /* input image dimensions */ |
56 |
|
|
57 |
< |
int (*putprim)() = Aputprim; /* function for writing scanline */ |
57 |
> |
typedef void putprimf_t(COLR *scn, int pri); |
58 |
|
|
59 |
< |
char *progname; |
59 |
> |
static gethfunc headline; |
60 |
> |
static putprimf_t Aputprim, Bputprim, Cputprim; |
61 |
|
|
62 |
< |
int xmax, ymax; /* input image dimensions */ |
62 |
> |
static double unit2inch(register char *s); |
63 |
> |
static int matchid(char *name, char *id); |
64 |
> |
static void parsepaper(char *ps); |
65 |
> |
static void quiterr(char *err); |
66 |
> |
static void PSheader(int ac, char **av); |
67 |
> |
static void PStrailer(void); |
68 |
> |
static void PSprocdef(char *nam); |
69 |
> |
static void ra2ps(void); |
70 |
> |
static void putrle(int cnt, int cod); |
71 |
|
|
60 |
– |
extern double unit2inch(); |
72 |
|
|
73 |
+ |
putprimf_t *putprim = Aputprim; /* function for writing scanline */ |
74 |
|
|
75 |
< |
int |
76 |
< |
headline(s) /* check header line */ |
77 |
< |
char *s; |
75 |
> |
|
76 |
> |
static int |
77 |
> |
headline( /* check header line */ |
78 |
> |
char *s, |
79 |
> |
void *p |
80 |
> |
) |
81 |
|
{ |
82 |
|
char fmt[32]; |
83 |
|
|
89 |
|
return(0); |
90 |
|
} |
91 |
|
|
92 |
< |
|
93 |
< |
main(argc, argv) |
79 |
< |
int argc; |
80 |
< |
char *argv[]; |
92 |
> |
int |
93 |
> |
main(int argc, char *argv[]) |
94 |
|
{ |
95 |
|
int i; |
96 |
|
double d; |
195 |
|
} |
196 |
|
|
197 |
|
|
198 |
< |
double |
199 |
< |
unit2inch(s) /* determine unit */ |
200 |
< |
register char *s; |
198 |
> |
static double |
199 |
> |
unit2inch( /* determine unit */ |
200 |
> |
register char *s |
201 |
> |
) |
202 |
|
{ |
203 |
|
static struct unit {char n; float f;} u[] = { |
204 |
< |
'i', 1., |
205 |
< |
'm', 1./25.4, |
206 |
< |
'c', 1./2.54, |
207 |
< |
'\0' }; |
204 |
> |
{'i', 1.}, |
205 |
> |
{'m', 1./25.4}, |
206 |
> |
{'c', 1./2.54}, |
207 |
> |
{'\0',0} }; |
208 |
|
register struct unit *up; |
209 |
|
|
210 |
|
while (*s && !isalpha(*s)) |
216 |
|
} |
217 |
|
|
218 |
|
|
219 |
< |
int |
220 |
< |
matchid(name, id) /* see if name matches id (case insensitive) */ |
221 |
< |
char *name; |
222 |
< |
register char *id; |
219 |
> |
static int |
220 |
> |
matchid( /* see if name matches id (case insensitive) */ |
221 |
> |
char *name, |
222 |
> |
register char *id |
223 |
> |
) |
224 |
|
{ |
225 |
|
register char *s = name; |
226 |
|
|
236 |
|
} |
237 |
|
|
238 |
|
|
239 |
< |
parsepaper(ps) /* determine paper size from name */ |
240 |
< |
char *ps; |
239 |
> |
static void |
240 |
> |
parsepaper( /* determine paper size from name */ |
241 |
> |
char *ps |
242 |
> |
) |
243 |
|
{ |
244 |
|
static struct psize {char n[12]; float w,h;} p[] = { |
245 |
< |
"envelope", 4.12, 9.5, |
246 |
< |
"executive", 7.25, 10.5, |
247 |
< |
"letter", 8.5, 11., |
248 |
< |
"lettersmall", 7.68, 10.16, |
249 |
< |
"legal", 8.5, 14., |
250 |
< |
"monarch", 3.87, 7.5, |
251 |
< |
"statement", 5.5, 8.5, |
252 |
< |
"tabloid", 11., 17., |
253 |
< |
"A3", 11.69, 16.54, |
254 |
< |
"A4", 8.27, 11.69, |
255 |
< |
"A4small", 7.47, 10.85, |
256 |
< |
"A5", 6.00, 8.27, |
257 |
< |
"A6", 4.13, 6.00, |
258 |
< |
"B4", 10.12, 14.33, |
259 |
< |
"B5", 7.17, 10.12, |
260 |
< |
"C5", 6.38, 9.01, |
261 |
< |
"C6", 4.49, 6.38, |
262 |
< |
"DL", 4.33, 8.66, |
263 |
< |
"hagaki", 3.94, 5.83, |
264 |
< |
"" }; |
245 |
> |
{"envelope", 4.12, 9.5}, |
246 |
> |
{"executive", 7.25, 10.5}, |
247 |
> |
{"letter", 8.5, 11.}, |
248 |
> |
{"lettersmall", 7.68, 10.16}, |
249 |
> |
{"legal", 8.5, 14.}, |
250 |
> |
{"monarch", 3.87, 7.5}, |
251 |
> |
{"statement", 5.5, 8.5}, |
252 |
> |
{"tabloid", 11., 17.}, |
253 |
> |
{"A3", 11.69, 16.54}, |
254 |
> |
{"A4", 8.27, 11.69}, |
255 |
> |
{"A4small", 7.47, 10.85}, |
256 |
> |
{"A5", 6.00, 8.27}, |
257 |
> |
{"A6", 4.13, 6.00}, |
258 |
> |
{"B4", 10.12, 14.33}, |
259 |
> |
{"B5", 7.17, 10.12}, |
260 |
> |
{"C5", 6.38, 9.01}, |
261 |
> |
{"C6", 4.49, 6.38}, |
262 |
> |
{"DL", 4.33, 8.66}, |
263 |
> |
{"hagaki", 3.94, 5.83}, |
264 |
> |
{"",0.0,0.0} }; |
265 |
|
register struct psize *pp; |
266 |
|
register char *s = ps; |
267 |
|
double d; |
293 |
|
} |
294 |
|
|
295 |
|
|
296 |
< |
quiterr(err) /* print message and exit */ |
297 |
< |
char *err; |
296 |
> |
static void |
297 |
> |
quiterr( /* print message and exit */ |
298 |
> |
char *err |
299 |
> |
) |
300 |
|
{ |
301 |
|
if (err != NULL) { |
302 |
|
fprintf(stderr, "%s: %s\n", progname, err); |
306 |
|
} |
307 |
|
|
308 |
|
|
309 |
< |
PSheader(ac, av) /* print PostScript header */ |
310 |
< |
int ac; |
311 |
< |
char **av; |
309 |
> |
static void |
310 |
> |
PSheader( /* print PostScript header */ |
311 |
> |
int ac, |
312 |
> |
char **av |
313 |
> |
) |
314 |
|
{ |
315 |
|
char *rstr; |
316 |
|
int landscape, rotate, n; |
407 |
|
} |
408 |
|
|
409 |
|
|
410 |
< |
PStrailer() /* print PostScript trailer */ |
410 |
> |
static void |
411 |
> |
PStrailer(void) /* print PostScript trailer */ |
412 |
|
{ |
413 |
|
puts("%%Trailer"); |
414 |
|
if (ncopies > 1) |
420 |
|
} |
421 |
|
|
422 |
|
|
423 |
< |
PSprocdef(nam) /* define PS procedure to read image */ |
424 |
< |
char *nam; |
423 |
> |
static void |
424 |
> |
PSprocdef( /* define PS procedure to read image */ |
425 |
> |
char *nam |
426 |
> |
) |
427 |
|
{ |
428 |
|
short itab[128]; |
429 |
|
register int i; |
431 |
|
for (i = 0; i < 128; i++) /* clear */ |
432 |
|
itab[i] = -1; |
433 |
|
for (i = 1; i < 63; i++) /* assign greys */ |
434 |
< |
itab[code[i]] = 256.0*pow((i+.5)/64.0, CODE6GAM/devgam); |
435 |
< |
itab[code[0]] = 0; /* black is black */ |
436 |
< |
itab[code[63]] = 255; /* and white is white */ |
434 |
> |
itab[(int)code[i]] = 256.0*pow((i+.5)/64.0, CODE6GAM/devgam); |
435 |
> |
itab[(int)code[0]] = 0; /* black is black */ |
436 |
> |
itab[(int)code[63]] = 255; /* and white is white */ |
437 |
|
printf("/codetab ["); |
438 |
|
for (i = 0; i < 128; i++) { |
439 |
|
if (!(i & 0xf)) |
462 |
|
} |
463 |
|
|
464 |
|
|
465 |
< |
ra2ps() /* convert Radiance scanlines to 6-bit */ |
465 |
> |
static void |
466 |
> |
ra2ps(void) /* convert Radiance scanlines to 6-bit */ |
467 |
|
{ |
468 |
|
register COLR *scanin; |
469 |
|
int y; |
496 |
|
} |
497 |
|
|
498 |
|
|
499 |
< |
int |
500 |
< |
Aputprim(scn, pri) /* put out hex ASCII primary from scanline */ |
501 |
< |
COLR *scn; |
502 |
< |
int pri; |
499 |
> |
static void |
500 |
> |
Aputprim( /* put out hex ASCII primary from scanline */ |
501 |
> |
COLR *scn, |
502 |
> |
int pri |
503 |
> |
) |
504 |
|
{ |
505 |
|
static char hexdigit[] = "0123456789ABCDEF"; |
506 |
|
static int col = 0; |
522 |
|
} |
523 |
|
|
524 |
|
|
525 |
< |
int |
526 |
< |
Bputprim(scn, pri) /* put out binary primary from scanline */ |
527 |
< |
COLR *scn; |
528 |
< |
int pri; |
525 |
> |
static void |
526 |
> |
Bputprim( /* put out binary primary from scanline */ |
527 |
> |
COLR *scn, |
528 |
> |
int pri |
529 |
> |
) |
530 |
|
{ |
531 |
|
register int x, c; |
532 |
|
|
541 |
|
} |
542 |
|
|
543 |
|
|
544 |
< |
int |
545 |
< |
Cputprim(scn, pri) /* put out compressed primary from scanline */ |
546 |
< |
COLR *scn; |
547 |
< |
int pri; |
544 |
> |
static void |
545 |
> |
Cputprim( /* put out compressed primary from scanline */ |
546 |
> |
COLR *scn, |
547 |
> |
int pri |
548 |
> |
) |
549 |
|
{ |
550 |
|
register int c; |
551 |
|
register int x; |
571 |
|
} |
572 |
|
|
573 |
|
|
574 |
< |
putrle(cnt, cod) /* put out cnt of cod */ |
575 |
< |
register int cnt, cod; |
574 |
> |
static void |
575 |
> |
putrle( /* put out cnt of cod */ |
576 |
> |
register int cnt, |
577 |
> |
register int cod |
578 |
> |
) |
579 |
|
{ |
580 |
|
static int col = 0; |
581 |
|
|