24 |
|
char *name; /* file name */ |
25 |
|
FILE *fp; /* stream pointer */ |
26 |
|
COLOR *scan; /* input scanline */ |
27 |
+ |
COLOR coef; /* coefficient */ |
28 |
|
} input[MAXINP]; /* input pictures */ |
29 |
|
|
30 |
|
int nfiles; /* number of input files */ |
54 |
|
int argc; |
55 |
|
char *argv[]; |
56 |
|
{ |
57 |
< |
extern double l_redin(), l_grnin(), l_bluin(); |
57 |
> |
extern double l_redin(), l_grnin(), l_bluin(), atof(); |
58 |
> |
double f; |
59 |
|
int a; |
60 |
|
|
61 |
|
funset(vcolin[RED], 1, l_redin); |
66 |
|
if (argv[a][0] == '-') |
67 |
|
switch (argv[a][1]) { |
68 |
|
case '\0': |
69 |
+ |
case 's': |
70 |
+ |
case 'c': |
71 |
|
goto getfiles; |
72 |
|
case 'x': |
73 |
|
xres = atoi(argv[++a]); |
85 |
|
scompile(NULL, argv[++a]); |
86 |
|
break; |
87 |
|
default: |
88 |
< |
eputs("Usage: "); |
85 |
< |
eputs(argv[0]); |
86 |
< |
eputs(" [-w][-x xres][-y yres][-e expr][-f file] [picture ..]\n"); |
87 |
< |
quit(1); |
88 |
> |
goto usage; |
89 |
|
} |
90 |
|
else |
91 |
|
break; |
92 |
|
getfiles: |
93 |
+ |
for (nfiles = 0; nfiles < MAXINP; nfiles++) |
94 |
+ |
setcolor(input[nfiles].coef, 1.0, 1.0, 1.0); |
95 |
|
nfiles = 0; |
96 |
|
for ( ; a < argc; a++) { |
97 |
|
if (nfiles >= MAXINP) { |
99 |
|
eputs(": too many picture files\n"); |
100 |
|
quit(1); |
101 |
|
} |
102 |
< |
if (argv[a][0] == '-') { |
103 |
< |
input[nfiles].name = "<stdin>"; |
104 |
< |
input[nfiles].fp = stdin; |
105 |
< |
} else { |
102 |
> |
if (argv[a][0] == '-') |
103 |
> |
switch (argv[a][1]) { |
104 |
> |
case '\0': |
105 |
> |
input[nfiles].name = "<stdin>"; |
106 |
> |
input[nfiles].fp = stdin; |
107 |
> |
break; |
108 |
> |
case 's': |
109 |
> |
f = atof(argv[++a]); |
110 |
> |
scalecolor(input[nfiles].coef, f); |
111 |
> |
continue; |
112 |
> |
case 'c': |
113 |
> |
colval(input[nfiles].coef,RED)*=atof(argv[++a]); |
114 |
> |
colval(input[nfiles].coef,GRN)*=atof(argv[++a]); |
115 |
> |
colval(input[nfiles].coef,BLU)*=atof(argv[++a]); |
116 |
> |
continue; |
117 |
> |
default: |
118 |
> |
goto usage; |
119 |
> |
} |
120 |
> |
else { |
121 |
|
input[nfiles].name = argv[a]; |
122 |
|
input[nfiles].fp = fopen(argv[a], "r"); |
123 |
|
if (input[nfiles].fp == NULL) { |
150 |
|
printf("-Y %d +X %d\n", yres, xres); |
151 |
|
combine(); |
152 |
|
quit(0); |
153 |
+ |
usage: |
154 |
+ |
eputs("Usage: "); |
155 |
+ |
eputs(argv[0]); |
156 |
+ |
eputs(" [-w][-x xr][-y yr][-e expr][-f file] [ [-s f][-c r g b] picture ..]\n"); |
157 |
+ |
quit(1); |
158 |
|
} |
159 |
|
|
160 |
|
|
182 |
|
eclock++; |
183 |
|
for (j = 0; j < 3; j++) |
184 |
|
if (coldef[j]) { |
185 |
< |
colval(scanout[xpos],j) = varvalue(vcolout[j]); |
185 |
> |
colval(scanout[xpos],j) = |
186 |
> |
varvalue(vcolout[j]); |
187 |
|
if (colval(scanout[xpos],j) < 0.0) |
188 |
|
colval(scanout[xpos],j) = 0.0; |
189 |
|
} else { |
190 |
|
colval(scanout[xpos],j) = 0.0; |
191 |
|
for (i = 0; i < nfiles; i++) |
192 |
< |
colval(scanout[xpos],j) += colval(input[i].scan[xpos],j); |
192 |
> |
colval(scanout[xpos],j) += |
193 |
> |
colval(input[i].coef,j) * |
194 |
> |
colval(input[i].scan[xpos],j); |
195 |
|
} |
196 |
|
} |
197 |
|
if (fwritescan(scanout, xres, stdout) < 0) { |