--- ray/src/px/ra_pr.c 1991/08/07 08:36:31 1.11 +++ ray/src/px/ra_pr.c 2003/02/22 02:07:28 2.6 @@ -1,9 +1,6 @@ -/* Copyright (c) 1991 Regents of the University of California */ - #ifndef lint -static char SCCSid[] = "$SunId$ LBL"; +static const char RCSid[] = "$Id: ra_pr.c,v 2.6 2003/02/22 02:07:28 greg Exp $"; #endif - /* * ra_pr.c - program to convert between RADIANCE and pixrect picture format. * @@ -13,10 +10,16 @@ static char SCCSid[] = "$SunId$ LBL"; #include +#include + +#include + #include "rasterfile.h" #include "color.h" +#include "resolu.h" + #include "pic.h" /* descriptor for a picture file or frame buffer */ @@ -37,10 +40,8 @@ extern char *ecalloc(), *emalloc(); extern long ftell(); -extern double atof(), pow(); +double gamcor = 2.2; /* gamma correction */ -double gamma = 2.0; /* gamma correction */ - int bradj = 0; /* brightness adjustment */ pic *inpic, *outpic; @@ -75,7 +76,7 @@ char *argv[]; dither = !dither; break; case 'g': - gamma = atof(argv[++i]); + gamcor = atof(argv[++i]); break; case 'b': greyscale = !greyscale; @@ -120,10 +121,11 @@ char *argv[]; head.ras_depth != 8) quiterr("incompatible format"); /* put header */ + newheader("RADIANCE", stdout); printargs(i, argv, stdout); fputformat(COLRFMT, stdout); putchar('\n'); - fputresolu(YMAJOR|YDECR, xmax, ymax, stdout); + fprtresolu(xmax, ymax, stdout); /* convert file */ pr2ra(&head); } else { @@ -166,6 +168,7 @@ char *err; } +void eputs(s) char *s; { @@ -173,6 +176,7 @@ char *s; } +void quit(code) int code; { @@ -195,7 +199,7 @@ register struct rasterfile *h; return(NULL); /* check header */ if (checkheader(p->fp, COLRFMT, NULL) < 0 || - fgetresolu(&xmax, &ymax, p->fp) != (YMAJOR|YDECR)) + fgetresolu(&xmax, &ymax, p->fp) < 0) quiterr("bad picture format"); p->nexty = 0; p->bytes_line = 0; /* variable length lines */ @@ -256,9 +260,9 @@ struct rasterfile *h; /* convert table */ for (i = 0; i < h->ras_maplength/3; i++) setcolr(ctab[i], - pow((cmap[0][i]+.5)/256.,gamma), - pow((cmap[1][i]+.5)/256.,gamma), - pow((cmap[2][i]+.5)/256.,gamma)); + pow((cmap[0][i]+.5)/256.,gamcor), + pow((cmap[1][i]+.5)/256.,gamcor), + pow((cmap[2][i]+.5)/256.,gamcor)); if (bradj) shiftcolrs(ctab, 256, bradj); /* convert file */ @@ -273,7 +277,7 @@ struct rasterfile *h; if (fwritecolrs(scanline, xmax, stdout) < 0) quiterr("error writing RADIANCE file"); } - free((char *)scanline); + free((void *)scanline); } @@ -359,7 +363,7 @@ colormap map; register int i, val; for (i = 0; i < 256; i++) { - val = pow((i+0.5)/256.0, 1.0/gamma) * 256.0; + val = pow((i+0.5)/256.0, 1.0/gamcor) * 256.0; map[0][i] = map[1][i] = map[2][i] = val; } }