1 |
– |
/* Copyright (c) 1986 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_t8.c - program to convert between RADIANCE and |
6 |
|
* Targa 8-bit color-mapped images. |
10 |
|
|
11 |
|
#include <stdio.h> |
12 |
|
|
13 |
+ |
#include <time.h> |
14 |
+ |
|
15 |
|
#include "color.h" |
16 |
|
|
17 |
< |
#include "pic.h" |
17 |
> |
#include "resolu.h" |
18 |
|
|
19 |
|
#include "targa.h" |
20 |
|
|
21 |
< |
#ifndef BSD |
22 |
< |
#define bcopy(s,d,n) (void)memcpy(d,s,n) |
24 |
< |
extern char *memcpy(); |
21 |
> |
#ifdef MSDOS |
22 |
> |
#include <fcntl.h> |
23 |
|
#endif |
26 |
– |
/* descriptor for a picture file or frame buffer */ |
27 |
– |
typedef struct { |
28 |
– |
char *name; /* file name */ |
29 |
– |
FILE *fp; /* file pointer */ |
30 |
– |
int nexty; /* file positioning */ |
31 |
– |
int bytes_line; /* 0 == variable length lines */ |
32 |
– |
union { |
33 |
– |
long b; /* initial scanline */ |
34 |
– |
long *y; /* individual scanline */ |
35 |
– |
} pos; /* position(s) */ |
36 |
– |
} pic; |
24 |
|
|
25 |
< |
#define goodpic(h) (my_imType(h) && my_mapType(h)) |
26 |
< |
#define my_imType(h) (((h)->dataType==IM_CMAP || (h)->dataType==IM_CCMAP) \ |
25 |
> |
#include <math.h> |
26 |
> |
|
27 |
> |
#ifndef BSD |
28 |
> |
#define bcopy(s,d,n) (void)memcpy(d,s,n) |
29 |
> |
#endif |
30 |
> |
|
31 |
> |
#define goodpic(h) (my_imType(h) && my_mapType(h)) |
32 |
> |
#define my_imType(h) (((h)->dataType==IM_CMAP || (h)->dataType==IM_CCMAP) \ |
33 |
|
&& (h)->dataBits==8 && (h)->imType==0) |
34 |
< |
#define my_mapType(h) ((h)->mapType==CM_HASMAP && \ |
34 |
> |
#define my_mapType(h) ((h)->mapType==CM_HASMAP && \ |
35 |
|
((h)->CMapBits==24 || (h)->CMapBits==32)) |
36 |
|
|
37 |
< |
#define taralloc(h) (pixel *)emalloc((h)->x*(h)->y*sizeof(pixel)) |
37 |
> |
#define taralloc(h) (BYTE *)emalloc((h)->x*(h)->y) |
38 |
|
|
39 |
< |
extern pic *openinput(); |
39 |
> |
BYTE clrtab[256][3]; |
40 |
|
|
41 |
+ |
extern int samplefac; |
42 |
+ |
|
43 |
|
extern char *ecalloc(), *emalloc(); |
44 |
|
|
45 |
|
extern long ftell(); |
46 |
|
|
47 |
< |
extern double atof(), pow(); |
47 |
> |
double gamv = 2.2; /* gamv correction */ |
48 |
|
|
49 |
< |
double gamma = 2.0; /* gamma correction */ |
49 |
> |
int bradj = 0; /* brightness adjustment */ |
50 |
|
|
56 |
– |
pic *inpic; |
57 |
– |
|
51 |
|
char *progname; |
52 |
|
|
53 |
|
char errmsg[128]; |
54 |
|
|
55 |
< |
COLR *inline; |
55 |
> |
COLR *inl; |
56 |
|
|
57 |
< |
pixel *tarData; |
57 |
> |
BYTE *tarData; |
58 |
|
|
59 |
|
int xmax, ymax; |
60 |
|
|
63 |
|
int argc; |
64 |
|
char *argv[]; |
65 |
|
{ |
66 |
< |
colormap rasmap; |
74 |
< |
struct hdStruct head; |
66 |
> |
struct hdStruct head; |
67 |
|
int dither = 1; |
68 |
|
int reverse = 0; |
69 |
|
int ncolors = 256; |
70 |
|
int greyscale = 0; |
71 |
|
int i; |
72 |
< |
|
72 |
> |
#ifdef MSDOS |
73 |
> |
extern int _fmode; |
74 |
> |
_fmode = O_BINARY; |
75 |
> |
setmode(fileno(stdin), O_BINARY); |
76 |
> |
setmode(fileno(stdout), O_BINARY); |
77 |
> |
#endif |
78 |
|
progname = argv[0]; |
79 |
+ |
samplefac = 0; |
80 |
|
|
81 |
|
for (i = 1; i < argc; i++) |
82 |
|
if (argv[i][0] == '-') |
85 |
|
dither = !dither; |
86 |
|
break; |
87 |
|
case 'g': |
88 |
< |
gamma = atof(argv[++i]); |
88 |
> |
gamv = atof(argv[++i]); |
89 |
|
break; |
90 |
|
case 'r': |
91 |
|
reverse = !reverse; |
93 |
|
case 'b': |
94 |
|
greyscale = 1; |
95 |
|
break; |
96 |
+ |
case 'e': |
97 |
+ |
if (argv[i+1][0] != '+' && argv[i+1][0] != '-') |
98 |
+ |
goto userr; |
99 |
+ |
bradj = atoi(argv[++i]); |
100 |
+ |
break; |
101 |
|
case 'c': |
102 |
|
ncolors = atoi(argv[++i]); |
103 |
|
break; |
104 |
+ |
case 'n': |
105 |
+ |
samplefac = atoi(argv[++i]); |
106 |
+ |
break; |
107 |
|
default: |
108 |
|
goto userr; |
109 |
|
} |
110 |
|
else |
111 |
|
break; |
112 |
|
|
113 |
+ |
if (i < argc-2) |
114 |
+ |
goto userr; |
115 |
+ |
if (i <= argc-1 && freopen(argv[i], "r", stdin) == NULL) { |
116 |
+ |
sprintf(errmsg, "cannot open input \"%s\"", argv[i]); |
117 |
+ |
quiterr(errmsg); |
118 |
+ |
} |
119 |
+ |
if (i == argc-2 && freopen(argv[i+1], "w", stdout) == NULL) { |
120 |
+ |
sprintf(errmsg, "cannot open output \"%s\"", argv[i+1]); |
121 |
+ |
quiterr(errmsg); |
122 |
+ |
} |
123 |
|
if (reverse) { |
108 |
– |
if (i < argc-2) |
109 |
– |
goto userr; |
110 |
– |
if (i <= argc-1 && freopen(argv[i], "r", stdin) == NULL) { |
111 |
– |
sprintf(errmsg, "can't open input \"%s\"", argv[i]); |
112 |
– |
quiterr(errmsg); |
113 |
– |
} |
124 |
|
/* get header */ |
125 |
|
if (getthead(&head, NULL, stdin) < 0) |
126 |
|
quiterr("bad targa file"); |
128 |
|
quiterr("incompatible format"); |
129 |
|
xmax = head.x; |
130 |
|
ymax = head.y; |
121 |
– |
/* open output file */ |
122 |
– |
if (i == argc-2 && freopen(argv[i+1], "w", stdout) == NULL) { |
123 |
– |
sprintf(errmsg, "can't open output \"%s\"", argv[i+1]); |
124 |
– |
quiterr(errmsg); |
125 |
– |
} |
131 |
|
/* put header */ |
132 |
< |
printargs(argc, argv, stdout); |
132 |
> |
newheader("RADIANCE", stdout); |
133 |
> |
printargs(i, argv, stdout); |
134 |
> |
fputformat(COLRFMT, stdout); |
135 |
|
putchar('\n'); |
136 |
< |
fputresolu(YMAJOR|YDECR, xmax, ymax, stdout); |
136 |
> |
fprtresolu(xmax, ymax, stdout); |
137 |
|
/* convert file */ |
138 |
|
tg2ra(&head); |
139 |
|
} else { |
140 |
< |
if (i > argc-1 || i < argc-2) |
141 |
< |
goto userr; |
135 |
< |
if ((inpic = openinput(argv[i], &head)) == NULL) { |
136 |
< |
sprintf(errmsg, "can't open input \"%s\"", argv[i]); |
137 |
< |
quiterr(errmsg); |
138 |
< |
} |
139 |
< |
if (i == argc-2 && freopen(argv[i+1], "w", stdout) == NULL) { |
140 |
< |
sprintf(errmsg, "can't open output \"%s\"", argv[i+1]); |
141 |
< |
quiterr(errmsg); |
142 |
< |
} |
140 |
> |
if (getrhead(&head, stdin) < 0) |
141 |
> |
quiterr("bad Radiance input"); |
142 |
|
/* write header */ |
143 |
|
putthead(&head, NULL, stdout); |
144 |
|
/* convert file */ |
145 |
|
if (greyscale) |
146 |
< |
biq(dither,ncolors,1,rasmap); |
146 |
> |
getgrey(ncolors); |
147 |
|
else |
148 |
< |
ciq(dither,ncolors,1,rasmap); |
148 |
> |
getmapped(ncolors, dither); |
149 |
|
/* write data */ |
150 |
|
writetarga(&head, tarData, stdout); |
151 |
|
} |
152 |
|
quiterr(NULL); |
153 |
|
userr: |
154 |
|
fprintf(stderr, |
155 |
< |
"Usage: %s [-d][-c ncolors][-b][-g gamma] input [output]\n", |
155 |
> |
"Usage: %s [-d][-n samp][-c ncolors][-b][-g gamv][-e +/-stops] input [output]\n", |
156 |
|
progname); |
157 |
< |
fprintf(stderr, " Or: %s -r [-g gamma] [input [output]]\n", |
157 |
> |
fprintf(stderr, " Or: %s -r [-g gamv][-e +/-stops] [input [output]]\n", |
158 |
|
progname); |
159 |
|
exit(1); |
160 |
|
} |
193 |
|
} |
194 |
|
|
195 |
|
|
196 |
+ |
void |
197 |
|
eputs(s) |
198 |
|
char *s; |
199 |
|
{ |
201 |
|
} |
202 |
|
|
203 |
|
|
204 |
+ |
void |
205 |
|
quit(code) |
206 |
|
int code; |
207 |
|
{ |
210 |
|
|
211 |
|
|
212 |
|
getthead(hp, ip, fp) /* read header from input */ |
213 |
< |
struct hdStruct *hp; |
213 |
> |
struct hdStruct *hp; |
214 |
|
char *ip; |
215 |
|
register FILE *fp; |
216 |
|
{ |
243 |
|
|
244 |
|
|
245 |
|
putthead(hp, ip, fp) /* write header to output */ |
246 |
< |
struct hdStruct *hp; |
246 |
> |
struct hdStruct *hp; |
247 |
|
char *ip; |
248 |
|
register FILE *fp; |
249 |
|
{ |
270 |
|
} |
271 |
|
|
272 |
|
|
273 |
< |
pic * |
273 |
< |
openinput(fname, h) /* open RADIANCE input file */ |
274 |
< |
char *fname; |
273 |
> |
getrhead(h, fp) /* load RADIANCE input file header */ |
274 |
|
register struct hdStruct *h; |
275 |
+ |
FILE *fp; |
276 |
|
{ |
277 |
< |
register pic *p; |
278 |
< |
|
279 |
< |
p = (pic *)emalloc(sizeof(pic)); |
280 |
< |
p->name = fname; |
281 |
< |
if (fname == NULL) |
282 |
< |
p->fp = stdin; |
283 |
< |
else if ((p->fp = fopen(fname, "r")) == NULL) |
284 |
< |
return(NULL); |
285 |
< |
/* discard header */ |
286 |
< |
getheader(p->fp, NULL); |
287 |
< |
if (fgetresolu(&xmax, &ymax, p->fp) != (YMAJOR|YDECR)) |
288 |
< |
quiterr("bad picture size"); |
289 |
< |
p->nexty = 0; |
290 |
< |
p->bytes_line = 0; /* variable length lines */ |
291 |
< |
p->pos.y = (long *)ecalloc(ymax, sizeof(long)); |
292 |
< |
p->pos.y[0] = ftell(p->fp); |
277 |
> |
/* get header info. */ |
278 |
> |
if (checkheader(fp, COLRFMT, NULL) < 0 || |
279 |
> |
fgetresolu(&xmax, &ymax, fp) < 0) |
280 |
> |
return(-1); |
281 |
|
/* assign header */ |
282 |
|
h->textSize = 0; |
283 |
|
h->mapType = CM_HASMAP; |
292 |
|
h->dataBits = 8; |
293 |
|
h->imType = 0; |
294 |
|
/* allocate scanline */ |
295 |
< |
inline = (COLR *)emalloc(xmax*sizeof(COLR)); |
295 |
> |
inl = (COLR *)emalloc(xmax*sizeof(COLR)); |
296 |
|
/* allocate targa data */ |
297 |
|
tarData = taralloc(h); |
298 |
|
|
299 |
< |
return(p); |
299 |
> |
return(0); |
300 |
|
} |
301 |
|
|
302 |
|
|
303 |
|
tg2ra(hp) /* targa file to RADIANCE file */ |
304 |
< |
struct hdStruct *hp; |
304 |
> |
struct hdStruct *hp; |
305 |
|
{ |
306 |
|
union { |
307 |
|
BYTE c3[256][3]; |
312 |
|
register int i, j; |
313 |
|
|
314 |
|
/* get color table */ |
315 |
< |
if ((hp->CMapBits==24 ? fread((char *)map.c3,sizeof(map.c3),1,stdin) : |
316 |
< |
fread((char *)map.c4,sizeof(map.c4),1,stdin)) != 1) |
315 |
> |
if ((hp->CMapBits==24 ? fread((char *)(map.c3+hp->mapOrig), |
316 |
> |
3*hp->mapLength,1,stdin) : |
317 |
> |
fread((char *)(map.c4+hp->mapOrig), |
318 |
> |
4*hp->mapLength,1,stdin)) != 1) |
319 |
|
quiterr("error reading color table"); |
320 |
|
/* convert table */ |
321 |
|
for (i = hp->mapOrig; i < hp->mapOrig+hp->mapLength; i++) |
322 |
|
if (hp->CMapBits == 24) |
323 |
|
setcolr(ctab[i], |
324 |
< |
pow((map.c3[i][2]+.5)/256.,gamma), |
325 |
< |
pow((map.c3[i][1]+.5)/256.,gamma), |
326 |
< |
pow((map.c3[i][0]+.5)/256.,gamma)); |
324 |
> |
pow((map.c3[i][2]+.5)/256.,gamv), |
325 |
> |
pow((map.c3[i][1]+.5)/256.,gamv), |
326 |
> |
pow((map.c3[i][0]+.5)/256.,gamv)); |
327 |
|
else |
328 |
|
setcolr(ctab[i], |
329 |
< |
pow((map.c4[i][3]+.5)/256.,gamma), |
330 |
< |
pow((map.c4[i][2]+.5)/256.,gamma), |
331 |
< |
pow((map.c4[i][1]+.5)/256.,gamma)); |
332 |
< |
|
329 |
> |
pow((map.c4[i][3]+.5)/256.,gamv), |
330 |
> |
pow((map.c4[i][2]+.5)/256.,gamv), |
331 |
> |
pow((map.c4[i][1]+.5)/256.,gamv)); |
332 |
> |
if (bradj) |
333 |
> |
shiftcolrs(ctab, 256, bradj); |
334 |
|
/* allocate targa data */ |
335 |
|
tarData = taralloc(hp); |
336 |
|
/* get data */ |
344 |
|
if (fwritecolrs(scanline, xmax, stdout) < 0) |
345 |
|
quiterr("error writing RADIANCE file"); |
346 |
|
} |
347 |
< |
free((char *)scanline); |
348 |
< |
free((char *)tarData); |
347 |
> |
free((void *)scanline); |
348 |
> |
free((void *)tarData); |
349 |
|
} |
350 |
|
|
351 |
|
|
352 |
< |
picreadline3(y, l3) /* read in 3-byte scanline */ |
353 |
< |
int y; |
354 |
< |
register rgbpixel *l3; |
352 |
> |
getmapped(nc, dith) /* read in and quantize image */ |
353 |
> |
int nc; /* number of colors to use */ |
354 |
> |
int dith; /* use dithering? */ |
355 |
|
{ |
356 |
< |
register int i; |
356 |
> |
long fpos; |
357 |
> |
register int y; |
358 |
|
|
359 |
< |
if (inpic->nexty != y) { /* find scanline */ |
360 |
< |
if (inpic->bytes_line == 0) { |
361 |
< |
if (inpic->pos.y[y] == 0) { |
362 |
< |
while (inpic->nexty < y) { |
363 |
< |
if (freadcolrs(inline, xmax, inpic->fp) < 0) |
364 |
< |
quiterr("read error in picreadline3"); |
365 |
< |
inpic->pos.y[++inpic->nexty] = ftell(inpic->fp); |
366 |
< |
} |
367 |
< |
} else if (fseek(inpic->fp, inpic->pos.y[y], 0) == EOF) |
368 |
< |
quiterr("seek error in picreadline3"); |
369 |
< |
} else if (fseek(inpic->fp, y*inpic->bytes_line+inpic->pos.b, 0) == EOF) |
370 |
< |
quiterr("seek error in picreadline3"); |
371 |
< |
} else if (inpic->bytes_line == 0 && inpic->pos.y[inpic->nexty] == 0) |
372 |
< |
inpic->pos.y[inpic->nexty] = ftell(inpic->fp); |
381 |
< |
if (freadcolrs(inline, xmax, inpic->fp) < 0) /* read scanline */ |
382 |
< |
quiterr("read error in picreadline3"); |
383 |
< |
inpic->nexty = y+1; |
384 |
< |
/* convert scanline */ |
385 |
< |
normcolrs(inline, xmax, 0); |
386 |
< |
for (i = 0; i < xmax; i++) { |
387 |
< |
l3[i].r = inline[i][RED]; |
388 |
< |
l3[i].g = inline[i][GRN]; |
389 |
< |
l3[i].b = inline[i][BLU]; |
359 |
> |
setcolrgam(gamv); |
360 |
> |
fpos = ftell(stdin); |
361 |
> |
if ((samplefac ? neu_init(xmax*ymax) : new_histo(xmax*ymax)) == -1) |
362 |
> |
quiterr("cannot initialized histogram"); |
363 |
> |
for (y = ymax-1; y >= 0; y--) { |
364 |
> |
if (freadcolrs(inl, xmax, stdin) < 0) |
365 |
> |
quiterr("error reading Radiance input"); |
366 |
> |
if (bradj) |
367 |
> |
shiftcolrs(inl, xmax, bradj); |
368 |
> |
colrs_gambs(inl, xmax); |
369 |
> |
if (samplefac) |
370 |
> |
neu_colrs(inl, xmax); |
371 |
> |
else |
372 |
> |
cnt_colrs(inl, xmax); |
373 |
|
} |
374 |
+ |
if (fseek(stdin, fpos, 0) == EOF) |
375 |
+ |
quiterr("Radiance input must be from a file"); |
376 |
+ |
if (samplefac) /* map colors */ |
377 |
+ |
neu_clrtab(nc); |
378 |
+ |
else |
379 |
+ |
new_clrtab(nc); |
380 |
+ |
for (y = ymax-1; y >= 0; y--) { |
381 |
+ |
if (freadcolrs(inl, xmax, stdin) < 0) |
382 |
+ |
quiterr("error reading Radiance input"); |
383 |
+ |
if (bradj) |
384 |
+ |
shiftcolrs(inl, xmax, bradj); |
385 |
+ |
colrs_gambs(inl, xmax); |
386 |
+ |
if (samplefac) |
387 |
+ |
if (dith) |
388 |
+ |
neu_dith_colrs(tarData+y*xmax, inl, xmax); |
389 |
+ |
else |
390 |
+ |
neu_map_colrs(tarData+y*xmax, inl, xmax); |
391 |
+ |
else |
392 |
+ |
if (dith) |
393 |
+ |
dith_colrs(tarData+y*xmax, inl, xmax); |
394 |
+ |
else |
395 |
+ |
map_colrs(tarData+y*xmax, inl, xmax); |
396 |
+ |
} |
397 |
|
} |
398 |
|
|
399 |
|
|
400 |
< |
picwriteline(y, l) /* save output scanline */ |
401 |
< |
int y; |
396 |
< |
pixel *l; |
400 |
> |
getgrey(nc) /* read in and convert to greyscale image */ |
401 |
> |
int nc; /* number of colors to use */ |
402 |
|
{ |
403 |
< |
bcopy((char *)l, (char *)&tarData[(ymax-1-y)*xmax], xmax*sizeof(pixel)); |
403 |
> |
int y; |
404 |
> |
register BYTE *dp; |
405 |
> |
register int x; |
406 |
> |
|
407 |
> |
setcolrgam(gamv); |
408 |
> |
dp = tarData+xmax*ymax;; |
409 |
> |
for (y = ymax-1; y >= 0; y--) { |
410 |
> |
if (freadcolrs(inl, xmax, stdin) < 0) |
411 |
> |
quiterr("error reading Radiance input"); |
412 |
> |
if (bradj) |
413 |
> |
shiftcolrs(inl, xmax, bradj); |
414 |
> |
x = xmax; |
415 |
> |
while (x--) |
416 |
> |
inl[x][GRN] = normbright(inl[x]); |
417 |
> |
colrs_gambs(inl, xmax); |
418 |
> |
x = xmax; |
419 |
> |
if (nc < 256) |
420 |
> |
while (x--) |
421 |
> |
*--dp = ((long)inl[x][GRN]*nc+nc/2)>>8; |
422 |
> |
else |
423 |
> |
while (x--) |
424 |
> |
*--dp = inl[x][GRN]; |
425 |
> |
} |
426 |
> |
for (x = 0; x < nc; x++) |
427 |
> |
clrtab[x][RED] = clrtab[x][GRN] = |
428 |
> |
clrtab[x][BLU] = ((long)x*256+128)/nc; |
429 |
|
} |
430 |
|
|
431 |
|
|
432 |
|
writetarga(h, d, fp) /* write out targa data */ |
433 |
< |
struct hdStruct *h; |
434 |
< |
pixel *d; |
433 |
> |
struct hdStruct *h; |
434 |
> |
BYTE *d; |
435 |
|
FILE *fp; |
436 |
|
{ |
437 |
+ |
register int i, j; |
438 |
+ |
|
439 |
+ |
for (i = 0; i < h->mapLength; i++) /* write color map */ |
440 |
+ |
for (j = 2; j >= 0; j--) |
441 |
+ |
putc(clrtab[i][j], fp); |
442 |
|
if (h->dataType == IM_CMAP) { /* uncompressed */ |
443 |
< |
if (fwrite((char *)d,h->x*sizeof(pixel),h->y,fp) != h->y) |
443 |
> |
if (fwrite((char *)d,h->x*sizeof(BYTE),h->y,fp) != h->y) |
444 |
|
quiterr("error writing targa file"); |
445 |
|
return; |
446 |
|
} |
449 |
|
|
450 |
|
|
451 |
|
readtarga(h, data, fp) /* read in targa data */ |
452 |
< |
struct hdStruct *h; |
453 |
< |
pixel *data; |
452 |
> |
struct hdStruct *h; |
453 |
> |
BYTE *data; |
454 |
|
FILE *fp; |
455 |
|
{ |
456 |
|
register int cnt, c; |
457 |
< |
register pixel *dp; |
457 |
> |
register BYTE *dp; |
458 |
|
|
459 |
|
if (h->dataType == IM_CMAP) { /* uncompressed */ |
460 |
< |
if (fread((char *)data,h->x*sizeof(pixel),h->y,fp) != h->y) |
460 |
> |
if (fread((char *)data,h->x*sizeof(BYTE),h->y,fp) != h->y) |
461 |
|
goto readerr; |
462 |
|
return; |
463 |
|
} |
480 |
|
return; |
481 |
|
readerr: |
482 |
|
quiterr("error reading targa file"); |
448 |
– |
} |
449 |
– |
|
450 |
– |
|
451 |
– |
picwritecm(cm) /* write out color map */ |
452 |
– |
colormap cm; |
453 |
– |
{ |
454 |
– |
register int i, j; |
455 |
– |
|
456 |
– |
for (j = 0; j < 256; j++) |
457 |
– |
for (i = 2; i >= 0; i--) |
458 |
– |
putc(cm[i][j], stdout); |
459 |
– |
} |
460 |
– |
|
461 |
– |
|
462 |
– |
picreadcm(map) /* do gamma correction if requested */ |
463 |
– |
colormap map; |
464 |
– |
{ |
465 |
– |
register int i, val; |
466 |
– |
|
467 |
– |
for (i = 0; i < 256; i++) { |
468 |
– |
val = pow(i/256.0, 1.0/gamma) * 256.0; |
469 |
– |
map[0][i] = map[1][i] = map[2][i] = val; |
470 |
– |
} |
483 |
|
} |