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 |
|
* ra_t16.c - program to convert between RADIANCE and |
6 |
|
* Targa 16, 24 and 32-bit images. |
10 |
|
|
11 |
|
#include <stdio.h> |
12 |
|
|
13 |
+ |
#ifdef MSDOS |
14 |
+ |
#include <fcntl.h> |
15 |
+ |
#endif |
16 |
+ |
|
17 |
+ |
#include <time.h> |
18 |
+ |
|
19 |
+ |
#include <math.h> |
20 |
+ |
|
21 |
|
#include "color.h" |
22 |
|
|
23 |
|
#include "resolu.h" |
39 |
|
|
40 |
|
extern char *ecalloc(), *emalloc(); |
41 |
|
|
42 |
< |
extern double atof(), pow(); |
42 |
> |
double gamcor = 2.2; /* gamma correction */ |
43 |
|
|
39 |
– |
double gamma = 2.2; /* gamma correction */ |
40 |
– |
|
44 |
|
int bradj = 0; /* brightness adjustment */ |
45 |
|
|
46 |
|
char *progname; |
55 |
|
struct hdStruct head; |
56 |
|
int reverse = 0; |
57 |
|
int i; |
58 |
< |
|
58 |
> |
#ifdef MSDOS |
59 |
> |
extern int _fmode; |
60 |
> |
_fmode = O_BINARY; |
61 |
> |
setmode(fileno(stdin), O_BINARY); |
62 |
> |
setmode(fileno(stdout), O_BINARY); |
63 |
> |
#endif |
64 |
|
progname = argv[0]; |
65 |
|
|
66 |
|
head.dataBits = 16; |
68 |
|
if (argv[i][0] == '-') |
69 |
|
switch (argv[i][1]) { |
70 |
|
case 'g': |
71 |
< |
gamma = atof(argv[++i]); |
71 |
> |
gamcor = atof(argv[++i]); |
72 |
|
break; |
73 |
|
case 'r': |
74 |
|
reverse = !reverse; |
103 |
|
quiterr(msg); |
104 |
|
} |
105 |
|
/* set gamma */ |
106 |
< |
setcolrgam(gamma); |
106 |
> |
setcolrgam(gamcor); |
107 |
|
/* convert */ |
108 |
|
if (reverse) { |
109 |
|
/* get header */ |
112 |
|
if (!goodpic(&head)) |
113 |
|
quiterr("incompatible format"); |
114 |
|
/* put header */ |
115 |
+ |
newheader("RADIANCE", stdout); |
116 |
|
printargs(i, argv, stdout); |
117 |
|
fputformat(COLRFMT, stdout); |
118 |
|
putchar('\n'); |
173 |
|
} |
174 |
|
|
175 |
|
|
176 |
+ |
void |
177 |
|
eputs(s) |
178 |
|
char *s; |
179 |
|
{ |
181 |
|
} |
182 |
|
|
183 |
|
|
184 |
+ |
void |
185 |
|
quit(code) |
186 |
|
int code; |
187 |
|
{ |
292 |
|
if (fwritecolrs(scanline, hp->x, stdout) < 0) |
293 |
|
quiterr("error writing RADIANCE file"); |
294 |
|
} |
295 |
< |
free((char *)scanline); |
296 |
< |
free((char *)tarData); |
295 |
> |
free((void *)scanline); |
296 |
> |
free((void *)tarData); |
297 |
|
} |
298 |
|
|
299 |
|
|
341 |
|
/* write out targa data */ |
342 |
|
writetarga(hp, tarData, stdout); |
343 |
|
|
344 |
< |
free((char *)inl); |
345 |
< |
free((char *)tarData); |
344 |
> |
free((void *)inl); |
345 |
> |
free((void *)tarData); |
346 |
|
} |
347 |
|
|
348 |
|
|