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 |
|
|
50 |
|
int bradj = 0; /* brightness adjustment */ |
51 |
|
int ncopies = 1; /* number of copies */ |
52 |
|
|
55 |
– |
char *progname; |
53 |
|
int xmax, ymax; /* input image dimensions */ |
54 |
|
|
55 |
|
typedef void putprimf_t(COLR *scn, int pri); |
57 |
|
static gethfunc headline; |
58 |
|
static putprimf_t Aputprim, Bputprim, Cputprim; |
59 |
|
|
60 |
< |
static double unit2inch(register char *s); |
60 |
> |
static double unit2inch(char *s); |
61 |
|
static int matchid(char *name, char *id); |
62 |
|
static void parsepaper(char *ps); |
63 |
|
static void quiterr(char *err); |
79 |
|
{ |
80 |
|
char fmt[MAXFMTLEN]; |
81 |
|
|
82 |
< |
if (isformat(s)) { |
83 |
< |
formatval(fmt, s); |
84 |
< |
wrongformat = strcmp(fmt, COLRFMT); |
88 |
< |
} else if (isaspect(s)) |
82 |
> |
if (formatval(fmt, s)) |
83 |
> |
wrongformat = strcmp(fmt, COLRFMT) && strcmp(fmt, SPECFMT); |
84 |
> |
else if (isaspect(s)) |
85 |
|
pixaspect *= aspectval(s); |
86 |
+ |
else if (isncomp(s)) |
87 |
+ |
NCSAMP = ncompval(s); |
88 |
+ |
else if (iswlsplit(s)) |
89 |
+ |
wlsplitval(WLPART, s); |
90 |
|
return(0); |
91 |
|
} |
92 |
|
|
96 |
|
int i; |
97 |
|
double d; |
98 |
|
|
99 |
< |
progname = argv[0]; |
99 |
> |
fixargv0(argv[0]); /* assigns progname */ |
100 |
|
|
101 |
|
for (i = 1; i < argc; i++) |
102 |
|
if (argv[i][0] == '-') |
198 |
|
|
199 |
|
static double |
200 |
|
unit2inch( /* determine unit */ |
201 |
< |
register char *s |
201 |
> |
char *s |
202 |
|
) |
203 |
|
{ |
204 |
|
static struct unit {char n; float f;} u[] = { |
206 |
|
{'m', 1./25.4}, |
207 |
|
{'c', 1./2.54}, |
208 |
|
{'\0',0} }; |
209 |
< |
register struct unit *up; |
209 |
> |
struct unit *up; |
210 |
|
|
211 |
|
while (*s && !isalpha(*s)) |
212 |
|
s++; |
220 |
|
static int |
221 |
|
matchid( /* see if name matches id (case insensitive) */ |
222 |
|
char *name, |
223 |
< |
register char *id |
223 |
> |
char *id |
224 |
|
) |
225 |
|
{ |
226 |
< |
register char *s = name; |
226 |
> |
char *s = name; |
227 |
|
|
228 |
|
while (*s) { |
229 |
|
if (isalpha(*s)) { |
263 |
|
{"DL", 4.33, 8.66}, |
264 |
|
{"hagaki", 3.94, 5.83}, |
265 |
|
{"",0.0,0.0} }; |
266 |
< |
register struct psize *pp; |
267 |
< |
register char *s = ps; |
266 |
> |
struct psize *pp; |
267 |
> |
char *s = ps; |
268 |
|
double d; |
269 |
|
|
270 |
|
if (isdigit(*s)) { /* check for WWxHH specification */ |
427 |
|
) |
428 |
|
{ |
429 |
|
short itab[128]; |
430 |
< |
register int i; |
430 |
> |
int i; |
431 |
|
/* assign code values */ |
432 |
|
for (i = 0; i < 128; i++) /* clear */ |
433 |
|
itab[i] = -1; |
466 |
|
static void |
467 |
|
ra2ps(void) /* convert Radiance scanlines to 6-bit */ |
468 |
|
{ |
469 |
< |
register COLR *scanin; |
469 |
> |
COLR *scanin; |
470 |
|
int y; |
471 |
|
/* allocate scanline */ |
472 |
|
scanin = (COLR *)malloc(xmax*sizeof(COLR)); |
474 |
|
quiterr("out of memory in ra2ps"); |
475 |
|
/* convert image */ |
476 |
|
for (y = ymax-1; y >= 0; y--) { |
477 |
< |
if (freadcolrs(scanin, xmax, stdin) < 0) |
477 |
> |
if (fread2colrs(scanin, xmax, stdin, NCSAMP, WLPART) < 0) |
478 |
|
quiterr("error reading Radiance picture"); |
479 |
< |
if (putprim == Cputprim || devgam != 1.) { |
479 |
> |
if ((putprim == Cputprim) | (devgam != 1.)) { |
480 |
|
if (bradj) /* adjust exposure */ |
481 |
|
shiftcolrs(scanin, xmax, bradj); |
482 |
|
colrs_gambs(scanin, xmax); /* gamma compression */ |
505 |
|
{ |
506 |
|
static char hexdigit[] = "0123456789ABCDEF"; |
507 |
|
static int col = 0; |
508 |
< |
register int x, c; |
508 |
> |
int x, c; |
509 |
|
|
510 |
|
for (x = 0; x < xmax; x++) { |
511 |
|
if (pri == GRY) |
529 |
|
int pri |
530 |
|
) |
531 |
|
{ |
532 |
< |
register int x, c; |
532 |
> |
int x, c; |
533 |
|
|
534 |
|
for (x = 0; x < xmax; x++) { |
535 |
|
if (pri == GRY) |
548 |
|
int pri |
549 |
|
) |
550 |
|
{ |
551 |
< |
register int c; |
552 |
< |
register int x; |
551 |
> |
int c; |
552 |
> |
int x; |
553 |
|
int lastc, cnt; |
554 |
|
|
555 |
|
lastc = -1; cnt = 0; |
574 |
|
|
575 |
|
static void |
576 |
|
putrle( /* put out cnt of cod */ |
577 |
< |
register int cnt, |
578 |
< |
register int cod |
577 |
> |
int cnt, |
578 |
> |
int cod |
579 |
|
) |
580 |
|
{ |
581 |
|
static int col = 0; |