1 |
– |
/* Copyright (c) 1998 Silicon Graphics, Inc. */ |
2 |
– |
|
1 |
|
#ifndef lint |
2 |
< |
static char SCCSid[] = "$SunId$ SGI"; |
2 |
> |
static const char RCSid[] = "$Id$"; |
3 |
|
#endif |
6 |
– |
|
4 |
|
/* |
5 |
|
* Tone map SGILOG TIFF or Radiance picture and output 24-bit RGB TIFF |
6 |
|
*/ |
7 |
|
|
11 |
– |
#undef NOPROTO |
12 |
– |
#define NOPROTO 1 |
13 |
– |
|
8 |
|
#include <stdio.h> |
9 |
|
#include <math.h> |
10 |
+ |
#include <time.h> |
11 |
+ |
#include <string.h> |
12 |
+ |
|
13 |
|
#include "tiffio.h" |
14 |
|
#include "color.h" |
15 |
|
#include "tonemap.h" |
44 |
|
|
45 |
|
extern PICTURE *openpicture(); |
46 |
|
|
47 |
< |
#define closepicture(p) (fclose((p)->fp),free((char *)(p))) |
47 |
> |
#define closepicture(p) (fclose((p)->fp),free((void *)(p))) |
48 |
|
|
49 |
+ |
static gethfunc headline; |
50 |
|
|
51 |
< |
main(argc, argv) |
52 |
< |
int argc; |
53 |
< |
char *argv[]; |
51 |
> |
|
52 |
> |
int |
53 |
> |
main( |
54 |
> |
int argc, |
55 |
> |
char *argv[] |
56 |
> |
) |
57 |
|
{ |
58 |
|
PICTURE *pin = NULL; |
59 |
|
TIFF *tin = NULL; |
132 |
|
} |
133 |
|
|
134 |
|
|
135 |
< |
int |
136 |
< |
headline(s, pp) /* process line from header */ |
137 |
< |
char *s; |
138 |
< |
register PICTURE *pp; |
135 |
> |
static int |
136 |
> |
headline( /* process line from header */ |
137 |
> |
char *s, |
138 |
> |
void *pp |
139 |
> |
) |
140 |
|
{ |
141 |
|
register char *cp; |
142 |
|
|
144 |
|
if (*cp & 0x80) |
145 |
|
return(-1); /* non-ascii in header */ |
146 |
|
if (isaspect(s)) |
147 |
< |
pp->pa *= aspectval(s); |
147 |
> |
((PICTURE *)pp)->pa *= aspectval(s); |
148 |
|
else |
149 |
< |
formatval(pp->fmt, s); |
149 |
> |
formatval(((PICTURE *)pp)->fmt, s); |
150 |
|
return(0); |
151 |
|
} |
152 |
|
|
206 |
|
return(-1); |
207 |
|
/* figure out TIFF orientation */ |
208 |
|
for (orient = 8; --orient; ) |
209 |
< |
if (ortab[orient] == pp->rs.or) |
209 |
> |
if (ortab[orient] == pp->rs.rt) |
210 |
|
break; |
211 |
|
orient++; |
212 |
|
/* put out our image */ |
214 |
|
72., 72./pp->pa, 2, pix) != 0) |
215 |
|
return(-1); |
216 |
|
/* free data and we're done */ |
217 |
< |
free((char *)pix); |
217 |
> |
free((void *)pix); |
218 |
|
return(0); |
219 |
|
} |
220 |
|
|
229 |
|
BYTE *pix; |
230 |
|
/* check to make sure it's SGILOG */ |
231 |
|
TIFFGetFieldDefaulted(tp, TIFFTAG_PHOTOMETRIC, &phot); |
232 |
< |
if (phot != PHOTOMETRIC_LOGLUV && phot != PHOTOMETRIC_LOGL) { |
231 |
< |
if (!(flags & TM_F_NOSTDERR)) { |
232 |
< |
fputs(fname, stderr); |
233 |
< |
fputs(": TIFF must be in SGILOG format\n", stderr); |
234 |
< |
} |
235 |
< |
return(-1); |
236 |
< |
} |
237 |
< |
if (phot == PHOTOMETRIC_LOGL) |
232 |
> |
if ((phot == PHOTOMETRIC_LOGL) | (phot == PHOTOMETRIC_MINISBLACK)) |
233 |
|
flags |= TM_F_BW; |
234 |
|
/* read and tone map TIFF */ |
235 |
|
if (tmMapTIFF(&pix, &xsiz, &ysiz, flags, |
245 |
|
xres, yres, resunit, pix) != 0) |
246 |
|
return(-1); |
247 |
|
/* free data and we're done */ |
248 |
< |
free((char *)pix); |
248 |
> |
free((void *)pix); |
249 |
|
return(0); |
250 |
|
} |
251 |
|
|