1 |
< |
/* Copyright (c) 1986 Regents of the University of California */ |
1 |
> |
/* Copyright (c) 1991 Regents of the University of California */ |
2 |
|
|
3 |
|
#ifndef lint |
4 |
|
static char SCCSid[] = "$SunId$ LBL"; |
53 |
|
|
54 |
|
double gamma = 2.0; /* gamma correction */ |
55 |
|
|
56 |
+ |
int bradj = 0; /* brightness adjustment */ |
57 |
+ |
|
58 |
|
pic *inpic; |
59 |
|
|
60 |
|
char *progname; |
97 |
|
case 'b': |
98 |
|
greyscale = 1; |
99 |
|
break; |
100 |
+ |
case 'e': |
101 |
+ |
if (argv[i+1][0] != '+' && argv[i+1][0] != '-') |
102 |
+ |
goto userr; |
103 |
+ |
bradj = atoi(argv[++i]); |
104 |
+ |
break; |
105 |
|
case 'c': |
106 |
|
ncolors = atoi(argv[++i]); |
107 |
|
break; |
138 |
|
/* convert file */ |
139 |
|
tg2ra(&head); |
140 |
|
} else { |
141 |
< |
if (i > argc-1 || i < argc-2) |
141 |
> |
if (i < argc-2 || (!greyscale && i > argc-1)) |
142 |
|
goto userr; |
143 |
|
if ((inpic = openinput(argv[i], &head)) == NULL) { |
144 |
|
sprintf(errmsg, "can't open input \"%s\"", argv[i]); |
161 |
|
quiterr(NULL); |
162 |
|
userr: |
163 |
|
fprintf(stderr, |
164 |
< |
"Usage: %s [-d][-c ncolors][-b][-g gamma] input [output]\n", |
164 |
> |
"Usage: %s [-d][-c ncolors][-b][-g gamma][-e +/-stops] input [output]\n", |
165 |
|
progname); |
166 |
< |
fprintf(stderr, " Or: %s -r [-g gamma] [input [output]]\n", |
166 |
> |
fprintf(stderr, " Or: %s -r [-g gamma][-e +/-stops] [input [output]]\n", |
167 |
|
progname); |
168 |
|
exit(1); |
169 |
|
} |
347 |
|
pow((map.c4[i][3]+.5)/256.,gamma), |
348 |
|
pow((map.c4[i][2]+.5)/256.,gamma), |
349 |
|
pow((map.c4[i][1]+.5)/256.,gamma)); |
350 |
< |
|
350 |
> |
if (bradj) |
351 |
> |
shiftcolrs(ctab, 256, bradj); |
352 |
|
/* allocate targa data */ |
353 |
|
tarData = taralloc(hp); |
354 |
|
/* get data */ |
391 |
|
quiterr("read error in picreadline3"); |
392 |
|
inpic->nexty = y+1; |
393 |
|
/* convert scanline */ |
394 |
< |
normcolrs(inl, xmax, 0); |
394 |
> |
normcolrs(inl, xmax, bradj); |
395 |
|
for (i = 0; i < xmax; i++) { |
396 |
|
l3[i].r = inl[i][RED]; |
397 |
|
l3[i].g = inl[i][GRN]; |