1 |
– |
/* Copyright (c) 1992 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 |
|
/* Convert an Radiance image to APPLE pict format. |
5 |
|
* |
6 |
|
* Orginally Iris to PICT by Paul Haeberli - 1990 |
17 |
|
*/ |
18 |
|
|
19 |
|
#include <stdio.h> |
20 |
+ |
#include <math.h> |
21 |
|
#ifdef MSDOS |
22 |
|
#include <fcntl.h> |
23 |
|
#endif |
24 |
+ |
#include <time.h> |
25 |
|
|
26 |
|
#include "pict.h" |
27 |
|
#include "color.h" |
28 |
|
#include "resolu.h" |
29 |
|
|
31 |
– |
extern char *malloc(); |
32 |
– |
|
30 |
|
int outbytes; /* This had better be 32 bits! */ |
31 |
|
char *progname; |
32 |
|
int verbose = 0; |
33 |
< |
float gamma = 2.0; |
33 |
> |
float gamcor = 2.0; |
34 |
|
int bradj = 0; |
35 |
|
|
36 |
|
/* First some utility routines */ |
108 |
|
for (i = 1; i < argc ; i++) |
109 |
|
if (argv[i][0] == '-') |
110 |
|
switch (argv[i][1]) { |
111 |
< |
case 'g': gamma = atof(argv[++i]); |
111 |
> |
case 'g': gamcor = atof(argv[++i]); |
112 |
|
break; |
113 |
|
|
114 |
|
case 'e': if (argv[i+1][0] != '+' && argv[i+1][0] != '-') |
154 |
|
#ifdef DEBUG |
155 |
|
fprintf(stderr, "Input file: %s\n", i <= argc - 1 ? argv[i] : "stdin"); |
156 |
|
fprintf(stderr, "Outut file: %s\n", i <= argc - 2 ? argv[i+1] : "stdout" ); |
157 |
< |
fprintf(stderr, "Gamma: %f\n", gamma); |
157 |
> |
fprintf(stderr, "Gamma: %f\n", gamcor); |
158 |
|
fprintf(stderr, "Brightness adjust: %d\n", bradj); |
159 |
|
fprintf(stderr, "Verbose: %s\n", verbose ? "on" : "off"); |
160 |
|
#endif |
169 |
|
|
170 |
|
/* Set the gamma correction */ |
171 |
|
|
172 |
< |
setcolrgam(gamma); |
172 |
> |
setcolrgam(gamcor); |
173 |
|
|
174 |
|
for(i=0; i<HEADER_SIZE; i++) |
175 |
|
putbyte(0); |
192 |
|
|
193 |
|
if (verbose) |
194 |
|
fprintf(stderr, "%s: The picture is %d by %d, with a gamma of %f\n", |
195 |
< |
progname, xsize, ysize, gamma); |
195 |
> |
progname, xsize, ysize, gamcor); |
196 |
|
|
197 |
|
|
198 |
|
putpict(xsize, ysize); /* Here is where all the work is done */ |
220 |
|
int nbytes, rowbytes; |
221 |
|
char *cbuf, *pbuf; |
222 |
|
|
223 |
< |
cbuf = malloc(4 * xsize); |
223 |
> |
cbuf = (char *)malloc(4 * xsize); |
224 |
|
|
225 |
|
if (cbuf == NULL) { |
226 |
|
fprintf(stderr, "%s: not enough memory\n", progname); |
227 |
|
exit(1); |
228 |
|
} |
229 |
|
|
230 |
< |
pbuf = malloc(4 * xsize); |
230 |
> |
pbuf = (char *)malloc(4 * xsize); |
231 |
|
|
232 |
|
if (pbuf == NULL) { |
233 |
|
fprintf(stderr, "%s: not enough memory\n", progname); |