1 |
– |
/* Copyright (c) 1988 Regents of the University of California */ |
2 |
– |
|
1 |
|
#ifndef lint |
2 |
< |
static char SCCSid[] = "$SunId$ LBL"; |
2 |
> |
static const char RCSid[] = "$Id$"; |
3 |
|
#endif |
6 |
– |
|
4 |
|
/* |
5 |
|
* Send pictures to PC animation system. |
6 |
|
* |
8 |
|
*/ |
9 |
|
|
10 |
|
#include <stdio.h> |
11 |
< |
#include <rasterfile.h> |
11 |
> |
#include <string.h> |
12 |
|
|
13 |
+ |
#include "rtprocess.h" |
14 |
|
#include "random.h" |
15 |
|
#include "color.h" |
16 |
|
#include "clntrpc.h" |
18 |
|
|
19 |
|
#define GAMMA 2.0 /* gamma correction factor */ |
20 |
|
|
23 |
– |
FILE *popen(); |
21 |
|
|
22 |
|
char *pcom = NULL; /* pipe command */ |
23 |
|
|
74 |
|
sendframe(file) /* convert and send a frame */ |
75 |
|
char *file; |
76 |
|
{ |
77 |
< |
char command[128]; |
77 |
> |
char command[PATH_MAX]; |
78 |
|
COLR scanin[SCANLINE]; |
79 |
|
int xres, yres; |
80 |
|
int xbeg, ybeg; |
90 |
|
file = "<stdin>"; |
91 |
|
} else { |
92 |
|
if (pcom != NULL) { |
93 |
< |
sprintf(command, "( %s ) < %s", pcom, file); |
93 |
> |
sprintf(command, "( %s ) < \"%s\"", pcom, file); |
94 |
|
fp = popen(command, "r"); |
95 |
|
} else |
96 |
|
fp = fopen(file, "r"); |
101 |
|
} |
102 |
|
/* get dimensions */ |
103 |
|
getheader(fp, NULL); |
104 |
+ |
if (checkheader(fp, COLRFMT, NULL) < 0) { |
105 |
+ |
fputs(file, stderr); |
106 |
+ |
fputs(": not a Radiance picture\n", stderr); |
107 |
+ |
exit(1); |
108 |
+ |
} |
109 |
|
if (fgetresolu(&xres, &yres, fp) != (YMAJOR|YDECR) || |
110 |
|
xres > SCANLINE || yres > NUMSCANS) { |
111 |
|
fputs(file, stderr); |
116 |
|
xbeg = (SCANLINE-xres)/2; |
117 |
|
ybeg = (NUMSCANS-yres)/2; |
118 |
|
/* clear output */ |
119 |
< |
bzero(sc_frame_arr, sizeof(sc_frame_arr)); |
119 |
> |
memset(sc_frame_arr, '\0', sizeof(sc_frame_arr)); |
120 |
|
/* get frame */ |
121 |
|
for (y = yres-1; y >= 0; y--) { |
122 |
|
if (freadcolrs(scanin, xres, fp) < 0) { |
147 |
|
register int i, val; |
148 |
|
|
149 |
|
for (i = 0; i < 256; i++) { |
150 |
< |
val = pow(i/256.0, 1.0/GAMMA) * 256.0; |
150 |
> |
val = pow((i+0.5)/256.0, 1.0/GAMMA) * 256.0; |
151 |
|
if (val > 248) val = 248; |
152 |
|
gammamap[i] = val; |
153 |
|
} |