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" |
59 |
|
static gethfunc headline; |
60 |
|
static putprimf_t Aputprim, Bputprim, Cputprim; |
61 |
|
|
62 |
< |
static double unit2inch(register char *s); |
62 |
> |
static double unit2inch(char *s); |
63 |
|
static int matchid(char *name, char *id); |
64 |
|
static void parsepaper(char *ps); |
65 |
|
static void quiterr(char *err); |
81 |
|
{ |
82 |
|
char fmt[MAXFMTLEN]; |
83 |
|
|
84 |
< |
if (isformat(s)) { |
85 |
< |
formatval(fmt, s); |
86 |
< |
wrongformat = strcmp(fmt, COLRFMT); |
88 |
< |
} else if (isaspect(s)) |
84 |
> |
if (formatval(fmt, s)) |
85 |
> |
wrongformat = strcmp(fmt, COLRFMT) && strcmp(fmt, SPECFMT); |
86 |
> |
else if (isaspect(s)) |
87 |
|
pixaspect *= aspectval(s); |
88 |
+ |
else if (isncomp(s)) |
89 |
+ |
NCSAMP = ncompval(s); |
90 |
+ |
else if (iswlsplit(s)) |
91 |
+ |
wlsplitval(WLPART, s); |
92 |
|
return(0); |
93 |
|
} |
94 |
|
|
200 |
|
|
201 |
|
static double |
202 |
|
unit2inch( /* determine unit */ |
203 |
< |
register char *s |
203 |
> |
char *s |
204 |
|
) |
205 |
|
{ |
206 |
|
static struct unit {char n; float f;} u[] = { |
208 |
|
{'m', 1./25.4}, |
209 |
|
{'c', 1./2.54}, |
210 |
|
{'\0',0} }; |
211 |
< |
register struct unit *up; |
211 |
> |
struct unit *up; |
212 |
|
|
213 |
|
while (*s && !isalpha(*s)) |
214 |
|
s++; |
222 |
|
static int |
223 |
|
matchid( /* see if name matches id (case insensitive) */ |
224 |
|
char *name, |
225 |
< |
register char *id |
225 |
> |
char *id |
226 |
|
) |
227 |
|
{ |
228 |
< |
register char *s = name; |
228 |
> |
char *s = name; |
229 |
|
|
230 |
|
while (*s) { |
231 |
|
if (isalpha(*s)) { |
265 |
|
{"DL", 4.33, 8.66}, |
266 |
|
{"hagaki", 3.94, 5.83}, |
267 |
|
{"",0.0,0.0} }; |
268 |
< |
register struct psize *pp; |
269 |
< |
register char *s = ps; |
268 |
> |
struct psize *pp; |
269 |
> |
char *s = ps; |
270 |
|
double d; |
271 |
|
|
272 |
|
if (isdigit(*s)) { /* check for WWxHH specification */ |
429 |
|
) |
430 |
|
{ |
431 |
|
short itab[128]; |
432 |
< |
register int i; |
432 |
> |
int i; |
433 |
|
/* assign code values */ |
434 |
|
for (i = 0; i < 128; i++) /* clear */ |
435 |
|
itab[i] = -1; |
468 |
|
static void |
469 |
|
ra2ps(void) /* convert Radiance scanlines to 6-bit */ |
470 |
|
{ |
471 |
< |
register COLR *scanin; |
471 |
> |
COLR *scanin; |
472 |
|
int y; |
473 |
|
/* allocate scanline */ |
474 |
|
scanin = (COLR *)malloc(xmax*sizeof(COLR)); |
476 |
|
quiterr("out of memory in ra2ps"); |
477 |
|
/* convert image */ |
478 |
|
for (y = ymax-1; y >= 0; y--) { |
479 |
< |
if (freadcolrs(scanin, xmax, stdin) < 0) |
479 |
> |
if (fread2colrs(scanin, xmax, stdin, NCSAMP, WLPART) < 0) |
480 |
|
quiterr("error reading Radiance picture"); |
481 |
< |
if (putprim == Cputprim || devgam != 1.) { |
481 |
> |
if ((putprim == Cputprim) | (devgam != 1.)) { |
482 |
|
if (bradj) /* adjust exposure */ |
483 |
|
shiftcolrs(scanin, xmax, bradj); |
484 |
|
colrs_gambs(scanin, xmax); /* gamma compression */ |
507 |
|
{ |
508 |
|
static char hexdigit[] = "0123456789ABCDEF"; |
509 |
|
static int col = 0; |
510 |
< |
register int x, c; |
510 |
> |
int x, c; |
511 |
|
|
512 |
|
for (x = 0; x < xmax; x++) { |
513 |
|
if (pri == GRY) |
531 |
|
int pri |
532 |
|
) |
533 |
|
{ |
534 |
< |
register int x, c; |
534 |
> |
int x, c; |
535 |
|
|
536 |
|
for (x = 0; x < xmax; x++) { |
537 |
|
if (pri == GRY) |
550 |
|
int pri |
551 |
|
) |
552 |
|
{ |
553 |
< |
register int c; |
554 |
< |
register int x; |
553 |
> |
int c; |
554 |
> |
int x; |
555 |
|
int lastc, cnt; |
556 |
|
|
557 |
|
lastc = -1; cnt = 0; |
576 |
|
|
577 |
|
static void |
578 |
|
putrle( /* put out cnt of cod */ |
579 |
< |
register int cnt, |
580 |
< |
register int cod |
579 |
> |
int cnt, |
580 |
> |
int cod |
581 |
|
) |
582 |
|
{ |
583 |
|
static int col = 0; |