--- ray/src/px/ra_bn.c 1991/04/18 14:35:35 1.7 +++ ray/src/px/ra_bn.c 1991/11/12 16:05:07 2.1 @@ -1,4 +1,4 @@ -/* Copyright (c) 1986 Regents of the University of California */ +/* Copyright (c) 1991 Regents of the University of California */ #ifndef lint static char SCCSid[] = "$SunId$ LBL"; @@ -14,10 +14,14 @@ static char SCCSid[] = "$SunId$ LBL"; #include "color.h" +#include "resolu.h" + extern double atof(), pow(); double gamma = 2.0; /* gamma correction */ +int bradj = 0; /* brightness adjustment */ + char *progname; char errmsg[128]; @@ -45,6 +49,11 @@ char *argv[]; case 'r': reverse = !reverse; break; + case 'e': + if (argv[i+1][0] != '+' && argv[i+1][0] != '-') + goto userr; + bradj = atoi(argv[++i]); + break; default: goto userr; } @@ -71,7 +80,7 @@ char *argv[]; printargs(i, argv, rafp); fputformat(COLRFMT, rafp); putc('\n', rafp); - fputresolu(YMAJOR|YDECR, xmax, ymax, rafp); + fprtresolu(xmax, ymax, rafp); /* convert file */ bn2ra(); } else { @@ -86,7 +95,7 @@ char *argv[]; } /* get header */ if (checkheader(rafp, COLRFMT, NULL) < 0 || - fgetresolu(&xmax, &ymax, rafp) != (YMAJOR|YDECR)) + fgetresolu(&xmax, &ymax, rafp) < 0) quiterr("bad RADIANCE format"); if (openbarney(argv[i+1], "w") < 0) { sprintf(errmsg, "cannot open output \"%s\"", argv[i+1]); @@ -97,9 +106,10 @@ char *argv[]; } quiterr(NULL); userr: - fprintf(stderr, "Usage: %s [-g gamma] {input|-} output\n", progname); - fprintf(stderr, " or: %s -r [-g gamma] input [output|-]\n", + fprintf(stderr, "Usage: %s [-g gamma][-e +/-stops] {input|-} output\n", progname); + fprintf(stderr, " or: %s -r [-g gamma][-e +/-stops] input [output|-]\n", + progname); exit(1); } @@ -177,6 +187,8 @@ ra2bn() /* convert radiance to barneyscan */ for (j = 0; j < ymax; j++) { if (freadcolrs(inl, xmax, rafp) < 0) quiterr("error reading RADIANCE file"); + if (bradj) + shiftcolrs(inl, xmax, bradj); colrs_gambs(inl, xmax); for (i = 0; i < xmax; i++) { putc(inl[i][RED], bnfp[0]); @@ -207,6 +219,8 @@ bn2ra() /* convert barneyscan to radiance */ if (feof(bnfp[0]) || feof(bnfp[1]) || feof(bnfp[2])) quiterr("error reading barney file"); gambs_colrs(outline, xmax); + if (bradj) + shiftcolrs(outline, xmax, bradj); if (fwritecolrs(outline, xmax, rafp) < 0) quiterr("error writing RADIANCE file"); }