1 |
< |
/* Copyright (c) 1991 Regents of the University of California */ |
1 |
> |
/* Copyright (c) 1992 Regents of the University of California */ |
2 |
|
|
3 |
|
#ifndef lint |
4 |
|
static char SCCSid[] = "$SunId$ LBL"; |
21 |
|
|
22 |
|
#include "targa.h" |
23 |
|
|
24 |
< |
#ifndef BSD |
25 |
< |
#define bcopy(s,d,n) (void)memcpy(d,s,n) |
24 |
> |
#ifdef MSDOS |
25 |
> |
#include <fcntl.h> |
26 |
> |
#endif |
27 |
> |
|
28 |
> |
#include <math.h> |
29 |
> |
|
30 |
> |
#ifndef BSD |
31 |
> |
#define bcopy(s,d,n) (void)memcpy(d,s,n) |
32 |
|
extern char *memcpy(); |
33 |
|
#endif |
34 |
|
/* descriptor for a picture file or frame buffer */ |
43 |
|
} pos; /* position(s) */ |
44 |
|
} pic; |
45 |
|
|
46 |
< |
#define goodpic(h) (my_imType(h) && my_mapType(h)) |
47 |
< |
#define my_imType(h) (((h)->dataType==IM_CMAP || (h)->dataType==IM_CCMAP) \ |
46 |
> |
#define goodpic(h) (my_imType(h) && my_mapType(h)) |
47 |
> |
#define my_imType(h) (((h)->dataType==IM_CMAP || (h)->dataType==IM_CCMAP) \ |
48 |
|
&& (h)->dataBits==8 && (h)->imType==0) |
49 |
< |
#define my_mapType(h) ((h)->mapType==CM_HASMAP && \ |
49 |
> |
#define my_mapType(h) ((h)->mapType==CM_HASMAP && \ |
50 |
|
((h)->CMapBits==24 || (h)->CMapBits==32)) |
51 |
|
|
52 |
< |
#define taralloc(h) (pixel *)emalloc((h)->x*(h)->y*sizeof(pixel)) |
52 |
> |
#define taralloc(h) (pixel *)emalloc((h)->x*(h)->y*sizeof(pixel)) |
53 |
|
|
54 |
|
extern pic *openinput(); |
55 |
|
|
57 |
|
|
58 |
|
extern long ftell(); |
59 |
|
|
54 |
– |
extern double pow(); |
55 |
– |
|
60 |
|
double gamma = 2.2; /* gamma correction */ |
61 |
|
|
62 |
|
int bradj = 0; /* brightness adjustment */ |
79 |
|
char *argv[]; |
80 |
|
{ |
81 |
|
colormap rasmap; |
82 |
< |
struct hdStruct head; |
82 |
> |
struct hdStruct head; |
83 |
|
int dither = 1; |
84 |
|
int reverse = 0; |
85 |
|
int ncolors = 256; |
86 |
|
int greyscale = 0; |
87 |
|
int i; |
88 |
< |
|
88 |
> |
#ifdef MSDOS |
89 |
> |
extern int _fmode; |
90 |
> |
_fmode = O_BINARY; |
91 |
> |
setmode(fileno(stdin), O_BINARY); |
92 |
> |
setmode(fileno(stdout), O_BINARY); |
93 |
> |
#endif |
94 |
|
progname = argv[0]; |
95 |
|
|
96 |
|
for (i = 1; i < argc; i++) |
228 |
|
|
229 |
|
|
230 |
|
getthead(hp, ip, fp) /* read header from input */ |
231 |
< |
struct hdStruct *hp; |
231 |
> |
struct hdStruct *hp; |
232 |
|
char *ip; |
233 |
|
register FILE *fp; |
234 |
|
{ |
261 |
|
|
262 |
|
|
263 |
|
putthead(hp, ip, fp) /* write header to output */ |
264 |
< |
struct hdStruct *hp; |
264 |
> |
struct hdStruct *hp; |
265 |
|
char *ip; |
266 |
|
register FILE *fp; |
267 |
|
{ |
332 |
|
|
333 |
|
|
334 |
|
tg2ra(hp) /* targa file to RADIANCE file */ |
335 |
< |
struct hdStruct *hp; |
335 |
> |
struct hdStruct *hp; |
336 |
|
{ |
337 |
|
union { |
338 |
|
BYTE c3[256][3]; |
422 |
|
|
423 |
|
|
424 |
|
writetarga(h, d, fp) /* write out targa data */ |
425 |
< |
struct hdStruct *h; |
425 |
> |
struct hdStruct *h; |
426 |
|
pixel *d; |
427 |
|
FILE *fp; |
428 |
|
{ |
436 |
|
|
437 |
|
|
438 |
|
readtarga(h, data, fp) /* read in targa data */ |
439 |
< |
struct hdStruct *h; |
439 |
> |
struct hdStruct *h; |
440 |
|
pixel *data; |
441 |
|
FILE *fp; |
442 |
|
{ |