9 |
|
* 2/26/88 |
10 |
|
*/ |
11 |
|
|
12 |
< |
#include <stdio.h> |
12 |
> |
#include "standard.h" |
13 |
|
|
14 |
|
#include "color.h" |
15 |
|
|
16 |
|
int xres, yres; /* input resolution */ |
17 |
+ |
double inpaspect = 1.0; /* input aspect ratio */ |
18 |
|
|
19 |
|
char buf[1<<20]; /* output buffer */ |
20 |
|
|
21 |
|
int nrows; /* number of rows output at once */ |
22 |
|
|
23 |
+ |
int wrongformat = 0; |
24 |
+ |
|
25 |
|
#define scanbar ((COLR *)buf) |
26 |
|
|
27 |
|
char *progname; |
28 |
|
|
29 |
|
|
30 |
+ |
headline(s) /* process line from header */ |
31 |
+ |
char *s; |
32 |
+ |
{ |
33 |
+ |
char fmt[32]; |
34 |
+ |
|
35 |
+ |
fputs(s, stdout); |
36 |
+ |
if (isaspect(s)) |
37 |
+ |
inpaspect *= aspectval(s); |
38 |
+ |
else if (isformat(s)) { |
39 |
+ |
formatval(fmt, s); |
40 |
+ |
wrongformat = strcmp(fmt, COLRFMT); |
41 |
+ |
} |
42 |
+ |
} |
43 |
+ |
|
44 |
+ |
|
45 |
|
main(argc, argv) |
46 |
|
int argc; |
47 |
|
char *argv[]; |
62 |
|
fprintf(stderr, "%s: cannot open\n", argv[2]); |
63 |
|
exit(1); |
64 |
|
} |
65 |
< |
/* copy header */ |
66 |
< |
copyheader(fin, stdout); |
65 |
> |
/* transfer header */ |
66 |
> |
getheader(fin, headline, NULL); |
67 |
> |
if (wrongformat) { |
68 |
> |
fprintf(stderr, "%s: wrong picture format\n", progname); |
69 |
> |
exit(1); |
70 |
> |
} |
71 |
|
/* add new header info. */ |
72 |
+ |
if (inpaspect < .99 || inpaspect > 1.01) |
73 |
+ |
fputaspect(1./inpaspect/inpaspect, stdout); |
74 |
|
printf("%s\n\n", progname); |
75 |
|
/* get picture size */ |
76 |
|
if (fgetresolu(&xres, &yres, fin) != (YMAJOR|YDECR)) { |