ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/px/ra_ps.c
(Generate patch)

Comparing ray/src/px/ra_ps.c (file contents):
Revision 2.16 by greg, Fri Oct 6 12:38:38 1995 UTC vs.
Revision 2.17 by gregl, Thu Sep 18 15:16:23 1997 UTC

# Line 1 | Line 1
1 < /* Copyright (c) 1995 Regents of the University of California */
1 > /* Copyright (c) 1997 Silicon Graphics, Inc. */
2  
3   #ifndef lint
4 < static char SCCSid[] = "$SunId$ LBL";
4 > static char SCCSid[] = "$SunId$ SGI";
5   #endif
6  
7   /*
# Line 15 | Line 15 | static char SCCSid[] = "$SunId$ LBL";
15   #endif
16   #include  "color.h"
17  
18 < #define GAMVAL          1.47                    /* gamma value for pixels */
18 > #define CODE6GAM        1.47                    /* gamma for 6-bit codes */
19 > #define DEFDGAM         1.0                     /* default device gamma */
20  
21   #define GRY             -1                      /* artificial index for grey */
22  
# Line 35 | Line 36 | char  code[] =                 /* 6-bit code lookup table */
36   int  wrongformat = 0;                   /* input in wrong format? */
37   double  pixaspect = 1.0;                /* pixel aspect ratio */
38  
39 + double  devgam = DEFDGAM;               /* device gamma response */
40   int  docolor = 0;                       /* produce color image? */
41   int  bradj = 0;                         /* brightness adjustment */
42   int  ncopies = 1;                       /* number of copies */
# Line 89 | Line 91 | char  *argv[];
91                          case 'C':               /* compressed ASCII encoding */
92                                  putprim = Cputprim;
93                                  break;
94 +                        case 'g':
95 +                                devgam = atof(argv[++i]);
96 +                                break;
97                          case 'e':               /* exposure adjustment */
98                                  if (argv[i+1][0] != '+' && argv[i+1][0] != '-')
99                                          goto userr;
# Line 124 | Line 129 | char  *argv[];
129                  quiterr("bad picture format");
130                                  /* gamma compression */
131          if (putprim == Cputprim)
132 <                setcolrgam(GAMVAL);
132 >                setcolrgam(CODE6GAM/devgam);
133 >        else if (devgam != 1.)
134 >                setcolrgam(1./devgam);
135                                  /* write header */
136          PSheader(i <= argc-1 ? argv[i] : "<stdin>");
137                                  /* convert file */
# Line 133 | Line 140 | char  *argv[];
140          PStrailer();
141          exit(0);
142   userr:
143 <        fprintf(stderr, "Usage: %s [-b|c][-A|B|C][-e +/-stops] [input [output]]\n",
143 >        fprintf(stderr, "Usage: %s [-b|c][-A|B|C][-e +/-stops][-g gamma] [input [output]]\n",
144                          progname);
145          exit(1);
146   }
# Line 258 | Line 265 | char  *nam;
265          for (i = 0; i < 128; i++)       /* clear */
266                  itab[i] = -1;
267          for (i = 1; i < 63; i++)        /* assign greys */
268 <                itab[code[i]] = 256.0*pow((i+.5)/64.0, GAMVAL);
268 >                itab[code[i]] = 256.0*pow((i+.5)/64.0, CODE6GAM);
269          itab[code[0]] = 0;              /* black is black */
270          itab[code[63]] = 255;           /* and white is white */
271          printf("/codetab [");
# Line 301 | Line 308 | ra2ps()                                /* convert Radiance scanlines to 6-bit */
308          for (y = ymax-1; y >= 0; y--) {
309                  if (freadcolrs(scanin, xmax, stdin) < 0)
310                          quiterr("error reading Radiance picture");
311 <                if (putprim == Cputprim) {
311 >                if (putprim == Cputprim || devgam != 1.) {
312                          if (bradj)                      /* adjust exposure */
313                                  shiftcolrs(scanin, xmax, bradj);
314                          colrs_gambs(scanin, xmax);      /* gamma compression */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines