1 |
– |
/* Copyright (c) 1991 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 |
|
* flip picture file horizontally and/or vertically |
6 |
|
*/ |
7 |
|
|
8 |
|
#include <stdio.h> |
9 |
+ |
#include <time.h> |
10 |
|
|
11 |
+ |
#include "platform.h" |
12 |
|
#include "color.h" |
14 |
– |
|
13 |
|
#include "resolu.h" |
14 |
|
|
15 |
|
int order; /* input orientation */ |
48 |
|
int argc; |
49 |
|
char *argv[]; |
50 |
|
{ |
51 |
< |
int i; |
52 |
< |
|
51 |
> |
static char picfmt[LPICFMT+1] = PICFMT; |
52 |
> |
int i, rval; |
53 |
> |
SET_DEFAULT_BINARY(); |
54 |
> |
SET_FILE_BINARY(stdout); |
55 |
|
progname = argv[0]; |
56 |
|
|
57 |
|
for (i = 1; i < argc; i++) |
77 |
|
exit(1); |
78 |
|
} |
79 |
|
/* transfer header */ |
80 |
< |
if (checkheader(fin, COLRFMT, stdout) < 0) { |
80 |
> |
if ((rval = checkheader(fin, picfmt, stdout)) < 0) { |
81 |
|
fprintf(stderr, "%s: input not a Radiance picture\n", |
82 |
|
progname); |
83 |
|
exit(1); |
84 |
|
} |
85 |
+ |
if (rval) |
86 |
+ |
fputformat(picfmt, stdout); |
87 |
|
/* add new header info. */ |
88 |
|
printargs(i, argv, stdout); |
87 |
– |
fputformat(COLRFMT, stdout); |
89 |
|
putchar('\n'); |
90 |
|
/* get picture size */ |
91 |
|
if ((order = fgetresolu(&xres, &yres, fin)) < 0) { |
119 |
|
memerr(); |
120 |
|
if ((scanin = (COLR *)malloc(xres*sizeof(COLR))) == NULL) |
121 |
|
memerr(); |
122 |
< |
for (y = yres-1; y >= 0; y--) { |
122 |
> |
for (y = yres-1; y > 0; y--) { |
123 |
|
scanpos[y] = ftell(fin); |
124 |
|
if (freadcolrs(scanin, xres, fin) < 0) { |
125 |
|
fprintf(stderr, "%s: read error\n", progname); |
126 |
|
exit(1); |
127 |
|
} |
128 |
|
} |
129 |
< |
free((char *)scanin); |
129 |
> |
scanpos[0] = ftell(fin); |
130 |
> |
free((void *)scanin); |
131 |
|
} |
132 |
|
|
133 |
|
|
161 |
|
exit(1); |
162 |
|
} |
163 |
|
} |
164 |
< |
free((char *)scanin); |
165 |
< |
free((char *)scanout); |
164 |
> |
free((void *)scanin); |
165 |
> |
if (fhoriz) |
166 |
> |
free((void *)scanout); |
167 |
|
} |