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