| 5 |
|
* Radiance picture to PostScript file translator -- one way! |
| 6 |
|
*/ |
| 7 |
|
|
| 8 |
– |
#include <stdio.h> |
| 9 |
– |
#include <string.h> |
| 8 |
|
#include <math.h> |
| 9 |
|
#include <ctype.h> |
| 10 |
|
|
| 11 |
|
#include "platform.h" |
| 12 |
+ |
#include "rtio.h" |
| 13 |
|
#include "color.h" |
| 14 |
|
#include "resolu.h" |
| 15 |
|
|
| 50 |
|
int bradj = 0; /* brightness adjustment */ |
| 51 |
|
int ncopies = 1; /* number of copies */ |
| 52 |
|
|
| 54 |
– |
extern int Aputprim(), Bputprim(), Cputprim(); |
| 55 |
– |
|
| 56 |
– |
int (*putprim)() = Aputprim; /* function for writing scanline */ |
| 57 |
– |
|
| 53 |
|
char *progname; |
| 59 |
– |
|
| 54 |
|
int xmax, ymax; /* input image dimensions */ |
| 55 |
|
|
| 56 |
< |
extern double unit2inch(); |
| 56 |
> |
typedef void putprimf_t(COLR *scn, int pri); |
| 57 |
|
|
| 58 |
|
static gethfunc headline; |
| 59 |
+ |
static putprimf_t Aputprim, Bputprim, Cputprim; |
| 60 |
|
|
| 61 |
+ |
static double unit2inch(register char *s); |
| 62 |
+ |
static int matchid(char *name, char *id); |
| 63 |
+ |
static void parsepaper(char *ps); |
| 64 |
+ |
static void quiterr(char *err); |
| 65 |
+ |
static void PSheader(int ac, char **av); |
| 66 |
+ |
static void PStrailer(void); |
| 67 |
+ |
static void PSprocdef(char *nam); |
| 68 |
+ |
static void ra2ps(void); |
| 69 |
+ |
static void putrle(int cnt, int cod); |
| 70 |
|
|
| 71 |
+ |
|
| 72 |
+ |
putprimf_t *putprim = Aputprim; /* function for writing scanline */ |
| 73 |
+ |
|
| 74 |
+ |
|
| 75 |
|
static int |
| 76 |
|
headline( /* check header line */ |
| 77 |
|
char *s, |
| 78 |
|
void *p |
| 79 |
|
) |
| 80 |
|
{ |
| 81 |
< |
char fmt[32]; |
| 81 |
> |
char fmt[MAXFMTLEN]; |
| 82 |
|
|
| 83 |
|
if (isformat(s)) { |
| 84 |
|
formatval(fmt, s); |
| 88 |
|
return(0); |
| 89 |
|
} |
| 90 |
|
|
| 91 |
< |
|
| 92 |
< |
main(argc, argv) |
| 85 |
< |
int argc; |
| 86 |
< |
char *argv[]; |
| 91 |
> |
int |
| 92 |
> |
main(int argc, char *argv[]) |
| 93 |
|
{ |
| 94 |
|
int i; |
| 95 |
|
double d; |
| 194 |
|
} |
| 195 |
|
|
| 196 |
|
|
| 197 |
< |
double |
| 198 |
< |
unit2inch(s) /* determine unit */ |
| 199 |
< |
register char *s; |
| 197 |
> |
static double |
| 198 |
> |
unit2inch( /* determine unit */ |
| 199 |
> |
register char *s |
| 200 |
> |
) |
| 201 |
|
{ |
| 202 |
|
static struct unit {char n; float f;} u[] = { |
| 203 |
|
{'i', 1.}, |
| 215 |
|
} |
| 216 |
|
|
| 217 |
|
|
| 218 |
< |
int |
| 219 |
< |
matchid(name, id) /* see if name matches id (case insensitive) */ |
| 220 |
< |
char *name; |
| 221 |
< |
register char *id; |
| 218 |
> |
static int |
| 219 |
> |
matchid( /* see if name matches id (case insensitive) */ |
| 220 |
> |
char *name, |
| 221 |
> |
register char *id |
| 222 |
> |
) |
| 223 |
|
{ |
| 224 |
|
register char *s = name; |
| 225 |
|
|
| 235 |
|
} |
| 236 |
|
|
| 237 |
|
|
| 238 |
< |
parsepaper(ps) /* determine paper size from name */ |
| 239 |
< |
char *ps; |
| 238 |
> |
static void |
| 239 |
> |
parsepaper( /* determine paper size from name */ |
| 240 |
> |
char *ps |
| 241 |
> |
) |
| 242 |
|
{ |
| 243 |
|
static struct psize {char n[12]; float w,h;} p[] = { |
| 244 |
|
{"envelope", 4.12, 9.5}, |
| 292 |
|
} |
| 293 |
|
|
| 294 |
|
|
| 295 |
< |
quiterr(err) /* print message and exit */ |
| 296 |
< |
char *err; |
| 295 |
> |
static void |
| 296 |
> |
quiterr( /* print message and exit */ |
| 297 |
> |
char *err |
| 298 |
> |
) |
| 299 |
|
{ |
| 300 |
|
if (err != NULL) { |
| 301 |
|
fprintf(stderr, "%s: %s\n", progname, err); |
| 305 |
|
} |
| 306 |
|
|
| 307 |
|
|
| 308 |
< |
PSheader(ac, av) /* print PostScript header */ |
| 309 |
< |
int ac; |
| 310 |
< |
char **av; |
| 308 |
> |
static void |
| 309 |
> |
PSheader( /* print PostScript header */ |
| 310 |
> |
int ac, |
| 311 |
> |
char **av |
| 312 |
> |
) |
| 313 |
|
{ |
| 314 |
|
char *rstr; |
| 315 |
|
int landscape, rotate, n; |
| 406 |
|
} |
| 407 |
|
|
| 408 |
|
|
| 409 |
< |
PStrailer() /* print PostScript trailer */ |
| 409 |
> |
static void |
| 410 |
> |
PStrailer(void) /* print PostScript trailer */ |
| 411 |
|
{ |
| 412 |
|
puts("%%Trailer"); |
| 413 |
|
if (ncopies > 1) |
| 419 |
|
} |
| 420 |
|
|
| 421 |
|
|
| 422 |
< |
PSprocdef(nam) /* define PS procedure to read image */ |
| 423 |
< |
char *nam; |
| 422 |
> |
static void |
| 423 |
> |
PSprocdef( /* define PS procedure to read image */ |
| 424 |
> |
char *nam |
| 425 |
> |
) |
| 426 |
|
{ |
| 427 |
|
short itab[128]; |
| 428 |
|
register int i; |
| 430 |
|
for (i = 0; i < 128; i++) /* clear */ |
| 431 |
|
itab[i] = -1; |
| 432 |
|
for (i = 1; i < 63; i++) /* assign greys */ |
| 433 |
< |
itab[code[i]] = 256.0*pow((i+.5)/64.0, CODE6GAM/devgam); |
| 434 |
< |
itab[code[0]] = 0; /* black is black */ |
| 435 |
< |
itab[code[63]] = 255; /* and white is white */ |
| 433 |
> |
itab[(int)code[i]] = 256.0*pow((i+.5)/64.0, CODE6GAM/devgam); |
| 434 |
> |
itab[(int)code[0]] = 0; /* black is black */ |
| 435 |
> |
itab[(int)code[63]] = 255; /* and white is white */ |
| 436 |
|
printf("/codetab ["); |
| 437 |
|
for (i = 0; i < 128; i++) { |
| 438 |
|
if (!(i & 0xf)) |
| 461 |
|
} |
| 462 |
|
|
| 463 |
|
|
| 464 |
< |
ra2ps() /* convert Radiance scanlines to 6-bit */ |
| 464 |
> |
static void |
| 465 |
> |
ra2ps(void) /* convert Radiance scanlines to 6-bit */ |
| 466 |
|
{ |
| 467 |
|
register COLR *scanin; |
| 468 |
|
int y; |
| 495 |
|
} |
| 496 |
|
|
| 497 |
|
|
| 498 |
< |
int |
| 499 |
< |
Aputprim(scn, pri) /* put out hex ASCII primary from scanline */ |
| 500 |
< |
COLR *scn; |
| 501 |
< |
int pri; |
| 498 |
> |
static void |
| 499 |
> |
Aputprim( /* put out hex ASCII primary from scanline */ |
| 500 |
> |
COLR *scn, |
| 501 |
> |
int pri |
| 502 |
> |
) |
| 503 |
|
{ |
| 504 |
|
static char hexdigit[] = "0123456789ABCDEF"; |
| 505 |
|
static int col = 0; |
| 521 |
|
} |
| 522 |
|
|
| 523 |
|
|
| 524 |
< |
int |
| 525 |
< |
Bputprim(scn, pri) /* put out binary primary from scanline */ |
| 526 |
< |
COLR *scn; |
| 527 |
< |
int pri; |
| 524 |
> |
static void |
| 525 |
> |
Bputprim( /* put out binary primary from scanline */ |
| 526 |
> |
COLR *scn, |
| 527 |
> |
int pri |
| 528 |
> |
) |
| 529 |
|
{ |
| 530 |
|
register int x, c; |
| 531 |
|
|
| 540 |
|
} |
| 541 |
|
|
| 542 |
|
|
| 543 |
< |
int |
| 544 |
< |
Cputprim(scn, pri) /* put out compressed primary from scanline */ |
| 545 |
< |
COLR *scn; |
| 546 |
< |
int pri; |
| 543 |
> |
static void |
| 544 |
> |
Cputprim( /* put out compressed primary from scanline */ |
| 545 |
> |
COLR *scn, |
| 546 |
> |
int pri |
| 547 |
> |
) |
| 548 |
|
{ |
| 549 |
|
register int c; |
| 550 |
|
register int x; |
| 570 |
|
} |
| 571 |
|
|
| 572 |
|
|
| 573 |
< |
putrle(cnt, cod) /* put out cnt of cod */ |
| 574 |
< |
register int cnt, cod; |
| 573 |
> |
static void |
| 574 |
> |
putrle( /* put out cnt of cod */ |
| 575 |
> |
register int cnt, |
| 576 |
> |
register int cod |
| 577 |
> |
) |
| 578 |
|
{ |
| 579 |
|
static int col = 0; |
| 580 |
|
|