13 |
|
|
14 |
|
#include <stdio.h> |
15 |
|
|
16 |
+ |
#include <math.h> |
17 |
+ |
|
18 |
|
#include "rasterfile.h" |
19 |
|
|
20 |
|
#include "color.h" |
21 |
|
|
22 |
+ |
#include "resolu.h" |
23 |
+ |
|
24 |
|
#include "pic.h" |
25 |
|
|
26 |
|
/* descriptor for a picture file or frame buffer */ |
41 |
|
|
42 |
|
extern long ftell(); |
43 |
|
|
44 |
< |
extern double atof(), pow(); |
44 |
> |
double gamcor = 2.2; /* gamma correction */ |
45 |
|
|
42 |
– |
double gamma = 2.2; /* gamma correction */ |
43 |
– |
|
46 |
|
int bradj = 0; /* brightness adjustment */ |
47 |
|
|
48 |
|
pic *inpic, *outpic; |
77 |
|
dither = !dither; |
78 |
|
break; |
79 |
|
case 'g': |
80 |
< |
gamma = atof(argv[++i]); |
80 |
> |
gamcor = atof(argv[++i]); |
81 |
|
break; |
82 |
|
case 'b': |
83 |
|
greyscale = !greyscale; |
125 |
|
printargs(i, argv, stdout); |
126 |
|
fputformat(COLRFMT, stdout); |
127 |
|
putchar('\n'); |
128 |
< |
fputresolu(YMAJOR|YDECR, xmax, ymax, stdout); |
128 |
> |
fprtresolu(xmax, ymax, stdout); |
129 |
|
/* convert file */ |
130 |
|
pr2ra(&head); |
131 |
|
} else { |
197 |
|
return(NULL); |
198 |
|
/* check header */ |
199 |
|
if (checkheader(p->fp, COLRFMT, NULL) < 0 || |
200 |
< |
fgetresolu(&xmax, &ymax, p->fp) != (YMAJOR|YDECR)) |
200 |
> |
fgetresolu(&xmax, &ymax, p->fp) < 0) |
201 |
|
quiterr("bad picture format"); |
202 |
|
p->nexty = 0; |
203 |
|
p->bytes_line = 0; /* variable length lines */ |
258 |
|
/* convert table */ |
259 |
|
for (i = 0; i < h->ras_maplength/3; i++) |
260 |
|
setcolr(ctab[i], |
261 |
< |
pow((cmap[0][i]+.5)/256.,gamma), |
262 |
< |
pow((cmap[1][i]+.5)/256.,gamma), |
263 |
< |
pow((cmap[2][i]+.5)/256.,gamma)); |
261 |
> |
pow((cmap[0][i]+.5)/256.,gamcor), |
262 |
> |
pow((cmap[1][i]+.5)/256.,gamcor), |
263 |
> |
pow((cmap[2][i]+.5)/256.,gamcor)); |
264 |
|
if (bradj) |
265 |
|
shiftcolrs(ctab, 256, bradj); |
266 |
|
/* convert file */ |
361 |
|
register int i, val; |
362 |
|
|
363 |
|
for (i = 0; i < 256; i++) { |
364 |
< |
val = pow((i+0.5)/256.0, 1.0/gamma) * 256.0; |
364 |
> |
val = pow((i+0.5)/256.0, 1.0/gamcor) * 256.0; |
365 |
|
map[0][i] = map[1][i] = map[2][i] = val; |
366 |
|
} |
367 |
|
} |