11 |
|
*/ |
12 |
|
|
13 |
|
#include <stdio.h> |
14 |
– |
#include <rasterfile.h> |
14 |
|
|
15 |
|
#include "random.h" |
16 |
|
#include "color.h" |
19 |
|
|
20 |
|
#define GAMMA 2.0 /* gamma correction factor */ |
21 |
|
|
22 |
+ |
FILE *popen(); |
23 |
+ |
|
24 |
+ |
char *pcom = NULL; /* pipe command */ |
25 |
+ |
|
26 |
|
BYTE gammamap[256]; /* gamma correction table */ |
27 |
|
|
28 |
|
|
38 |
|
for (progname = *argv++; --argc; argv++) |
39 |
|
if (!strcmp(*argv, "-p") && argv[1]) { |
40 |
|
port = atoi(*++argv); argc--; |
41 |
+ |
} else if (!strcmp(*argv, "-u") && argv[1]) { |
42 |
+ |
pcom = *++argv; argc--; |
43 |
|
} else |
44 |
|
break; |
45 |
|
if (!argc) { |
46 |
|
fputs("Usage: ", stderr); |
47 |
|
fputs(progname, stderr); |
48 |
< |
fputs(" [-p port] hostname [-c copies][-r record] [frame] ..\n", |
48 |
> |
fputs(" [-p port] [-u uncompress] hostname [-c copies][-r record] [frame] ..\n", |
49 |
|
stderr); |
50 |
|
exit(1); |
51 |
|
} |
76 |
|
sendframe(file) /* convert and send a frame */ |
77 |
|
char *file; |
78 |
|
{ |
79 |
+ |
char command[128]; |
80 |
|
COLR scanin[SCANLINE]; |
81 |
|
int xres, yres; |
82 |
|
int xbeg, ybeg; |
85 |
|
register int x; |
86 |
|
/* open file */ |
87 |
|
if (file == NULL) { |
88 |
< |
fp = stdin; |
88 |
> |
if (pcom != NULL) |
89 |
> |
fp = popen(pcom, "r"); |
90 |
> |
else |
91 |
> |
fp = stdin; |
92 |
|
file = "<stdin>"; |
93 |
< |
} else if ((fp = fopen(file, "r")) == NULL) { |
93 |
> |
} else { |
94 |
> |
if (pcom != NULL) { |
95 |
> |
sprintf(command, "( %s ) < %s", pcom, file); |
96 |
> |
fp = popen(command, "r"); |
97 |
> |
} else |
98 |
> |
fp = fopen(file, "r"); |
99 |
> |
} |
100 |
> |
if (fp == NULL) { |
101 |
|
perror(file); |
102 |
|
exit(1); |
103 |
|
} |
121 |
|
fputs(": read error\n", stderr); |
122 |
|
exit(1); |
123 |
|
} |
124 |
< |
normcolrs(scanin, xres); /* normalize */ |
124 |
> |
normcolrs(scanin, xres, 0); /* normalize */ |
125 |
|
for (x = 0; x < xres; x++) /* convert */ |
126 |
|
sc_frame_arr[y+ybeg][x+xbeg] = |
127 |
|
((gammamap[scanin[x][RED]]+(random()&7))&0xf8)<<7 |
131 |
|
/* send frame */ |
132 |
|
scry_send_frame(); |
133 |
|
/* close file */ |
134 |
< |
fclose(fp); |
134 |
> |
if (pcom != NULL) |
135 |
> |
pclose(fp); |
136 |
> |
else |
137 |
> |
fclose(fp); |
138 |
|
} |
139 |
|
|
140 |
|
|