72 |
|
|
73 |
|
double exposure = 1.0; /* exposure compensation used */ |
74 |
|
|
75 |
+ |
int wrongformat = 0; /* input in another format */ |
76 |
+ |
|
77 |
|
struct { |
78 |
|
int xmin, ymin, xsiz, ysiz; |
79 |
|
} box = {0, 0, 0, 0}; /* current box */ |
143 |
|
} |
144 |
|
} |
145 |
|
/* get header */ |
146 |
< |
getheader(fin, headline); |
146 |
> |
getheader(fin, headline, NULL); |
147 |
|
/* get picture dimensions */ |
148 |
< |
if (fgetresolu(&xmax, &ymax, fin) != (YMAJOR|YDECR)) |
148 |
> |
if (wrongformat || fgetresolu(&xmax, &ymax, fin) != (YMAJOR|YDECR)) |
149 |
|
quiterr("bad picture size"); |
150 |
|
/* set view parameters */ |
151 |
|
if (gotview && setview(&ourview) != NULL) |
170 |
|
{ |
171 |
|
static char *altname[] = {"rview","rpict",VIEWSTR,NULL}; |
172 |
|
register char **an; |
173 |
+ |
char fmt[32]; |
174 |
|
|
175 |
|
if (isexpos(s)) |
176 |
|
exposure *= exposval(s); |
177 |
< |
else |
177 |
> |
else if (isformat(s)) { |
178 |
> |
formatval(fmt, s); |
179 |
> |
wrongformat = strcmp(fmt, COLRFMT); |
180 |
> |
} else |
181 |
|
for (an = altname; *an != NULL; an++) |
182 |
|
if (!strncmp(*an, s, strlen(*an))) { |
183 |
|
if (sscanview(&ourview, s+strlen(*an)) > 0) |
293 |
|
} |
294 |
|
return; |
295 |
|
memerr: |
296 |
< |
quit("out of memory"); |
296 |
> |
quiterr("out of memory"); |
297 |
|
} |
298 |
|
|
299 |
|
|
379 |
|
sprintf(buf, "%.3f", intens(cval)/exposure); |
380 |
|
break; |
381 |
|
case 'l': /* luminance */ |
382 |
< |
sprintf(buf, "%.0fn", bright(cval)*683.0/exposure); |
382 |
> |
sprintf(buf, "%.0fL", luminance(cval)/exposure); |
383 |
|
break; |
384 |
|
case 'c': /* color */ |
385 |
|
comp = pow(2.0, (double)scale); |
554 |
|
|
555 |
|
if ((inl = (rgbpixel *)malloc(xmax*sizeof(rgbpixel))) == NULL |
556 |
|
|| (cerr = (short *)calloc(xmax,sizeof(short))) == NULL) |
557 |
< |
quit("out of memory in getmono"); |
557 |
> |
quiterr("out of memory in getmono"); |
558 |
|
dp = ourras->data.m - 1; |
559 |
|
for (y = 0; y < ymax; y++) { |
560 |
|
picreadline3(y, inl); |
641 |
|
if (scanpos == NULL || scanpos[y] == -1) |
642 |
|
return(-1); |
643 |
|
if (fseek(fin, scanpos[y], 0) == -1) |
644 |
< |
quit("fseek error"); |
644 |
> |
quiterr("fseek error"); |
645 |
|
cury = y; |
646 |
|
} else if (scanpos != NULL) |
647 |
|
scanpos[y] = ftell(fin); |
687 |
|
register int i, val; |
688 |
|
|
689 |
|
for (i = 0; i < 256; i++) { |
690 |
< |
val = pow(i/256.0, 1.0/gamcor) * 256.0; |
690 |
> |
val = pow((i+0.5)/256.0, 1.0/gamcor) * 256.0; |
691 |
|
map[0][i] = map[1][i] = map[2][i] = val; |
692 |
|
} |
693 |
|
} |