45 |
|
exit(1); |
46 |
|
} |
47 |
|
/* copy header */ |
48 |
< |
while (fgets(buf, sizeof(buf), fin) != NULL && buf[0] != '\n') |
49 |
< |
fputs(buf, stdout); |
48 |
> |
copyheader(fin, stdout); |
49 |
|
/* add new header info. */ |
50 |
|
printf("%s\n\n", progname); |
51 |
|
/* get picture size */ |
52 |
< |
if (fgets(buf, sizeof(buf), fin) == NULL || |
54 |
< |
sscanf(buf, "-Y %d +X %d\n", &yres, &xres) != 2) { |
52 |
> |
if (fgetresolu(&xres, &yres, fin) != (YMAJOR|YDECR)) { |
53 |
|
fprintf(stderr, "%s: bad picture size\n", progname); |
54 |
|
exit(1); |
55 |
|
} |
56 |
|
/* write new picture size */ |
57 |
< |
printf("-Y %d +X %d\n", xres, yres); |
57 |
> |
fputresolu(YMAJOR|YDECR, yres, xres, stdout); |
58 |
|
/* compute buffer capacity */ |
59 |
|
nrows = sizeof(buf)/sizeof(COLR)/yres; |
60 |
|
rotate(fin); /* rotate the image */ |
65 |
|
rotate(fp) /* rotate picture */ |
66 |
|
FILE *fp; |
67 |
|
{ |
68 |
< |
register COLR *inline; |
68 |
> |
register COLR *inln; |
69 |
|
register int xoff, inx, iny; |
70 |
|
long start, ftell(); |
71 |
|
|
72 |
< |
if ((inline = (COLR *)malloc(xres*sizeof(COLR))) == NULL) { |
72 |
> |
if ((inln = (COLR *)malloc(xres*sizeof(COLR))) == NULL) { |
73 |
|
fprintf(stderr, "%s: out of memory\n", progname); |
74 |
|
exit(1); |
75 |
|
} |
80 |
|
exit(1); |
81 |
|
} |
82 |
|
for (iny = yres-1; iny >= 0; iny--) { |
83 |
< |
if (freadcolrs(inline, xres, fp) < 0) { |
83 |
> |
if (freadcolrs(inln, xres, fp) < 0) { |
84 |
|
fprintf(stderr, "%s: read error\n", progname); |
85 |
|
exit(1); |
86 |
|
} |
87 |
|
for (inx = 0; inx < nrows && xoff+inx < xres; inx++) |
88 |
< |
bcopy(inline[xoff+inx], scanbar[inx*yres+iny], |
88 |
> |
bcopy((char *)inln[xoff+inx], |
89 |
> |
(char *)scanbar[inx*yres+iny], |
90 |
|
sizeof(COLR)); |
91 |
|
} |
92 |
|
for (inx = 0; inx < nrows && xoff+inx < xres; inx++) |
95 |
|
exit(1); |
96 |
|
} |
97 |
|
} |
98 |
< |
free((char *)inline); |
98 |
> |
free((char *)inln); |
99 |
|
} |