13 |
|
|
14 |
|
#include <stdio.h> |
15 |
|
|
16 |
+ |
#ifdef MSDOS |
17 |
+ |
#include <fcntl.h> |
18 |
+ |
#endif |
19 |
+ |
|
20 |
+ |
#include <math.h> |
21 |
+ |
|
22 |
|
#include "color.h" |
23 |
|
|
24 |
+ |
#include "resolu.h" |
25 |
+ |
|
26 |
|
#include "random.h" |
27 |
|
|
28 |
|
#include "targa.h" |
40 |
|
|
41 |
|
extern char *ecalloc(), *emalloc(); |
42 |
|
|
43 |
< |
extern double atof(), pow(); |
43 |
> |
double gamcor = 2.2; /* gamma correction */ |
44 |
|
|
37 |
– |
double gamma = 2.2; /* gamma correction */ |
38 |
– |
|
45 |
|
int bradj = 0; /* brightness adjustment */ |
46 |
|
|
47 |
|
char *progname; |
56 |
|
struct hdStruct head; |
57 |
|
int reverse = 0; |
58 |
|
int i; |
59 |
< |
|
59 |
> |
#ifdef MSDOS |
60 |
> |
extern int _fmode; |
61 |
> |
_fmode = O_BINARY; |
62 |
> |
setmode(fileno(stdin), O_BINARY); |
63 |
> |
setmode(fileno(stdout), O_BINARY); |
64 |
> |
#endif |
65 |
|
progname = argv[0]; |
66 |
|
|
67 |
|
head.dataBits = 16; |
69 |
|
if (argv[i][0] == '-') |
70 |
|
switch (argv[i][1]) { |
71 |
|
case 'g': |
72 |
< |
gamma = atof(argv[++i]); |
72 |
> |
gamcor = atof(argv[++i]); |
73 |
|
break; |
74 |
|
case 'r': |
75 |
|
reverse = !reverse; |
104 |
|
quiterr(msg); |
105 |
|
} |
106 |
|
/* set gamma */ |
107 |
< |
setcolrgam(gamma); |
107 |
> |
setcolrgam(gamcor); |
108 |
|
/* convert */ |
109 |
|
if (reverse) { |
110 |
|
/* get header */ |
116 |
|
printargs(i, argv, stdout); |
117 |
|
fputformat(COLRFMT, stdout); |
118 |
|
putchar('\n'); |
119 |
< |
fputresolu(YMAJOR|YDECR, head.x, head.y, stdout); |
119 |
> |
fprtresolu(head.x, head.y, stdout); |
120 |
|
/* convert file */ |
121 |
|
tg2ra(&head); |
122 |
|
} else { |
123 |
|
if (checkheader(stdin, COLRFMT, NULL) < 0 || |
124 |
< |
fgetresolu(&head.x, &head.y, stdin) != (YMAJOR|YDECR)) |
124 |
> |
fgetresolu(&head.x, &head.y, stdin) < 0) |
125 |
|
quiterr("bad picture file"); |
126 |
|
/* assign header */ |
127 |
|
head.textSize = 0; |