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

Comparing ray/src/px/ra_pr.c (file contents):
Revision 1.10 by greg, Thu Apr 18 14:35:38 1991 UTC vs.
Revision 2.3 by greg, Fri Oct 2 16:25:33 1992 UTC

# Line 1 | Line 1
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";
# Line 13 | Line 13 | static char SCCSid[] = "$SunId$ LBL";
13  
14   #include  <stdio.h>
15  
16 + #include  <math.h>
17 +
18   #include  "rasterfile.h"
19  
20   #include  "color.h"
21  
22 + #include  "resolu.h"
23 +
24   #include  "pic.h"
25  
26                          /* descriptor for a picture file or frame buffer */
# Line 37 | Line 41 | extern char    *ecalloc(), *emalloc();
41  
42   extern long  ftell();
43  
44 < extern double  atof(), pow();
44 > double  gamma = 2.2;                    /* gamma correction */
45  
46 < double  gamma = 2.0;                    /* gamma correction */
46 > int  bradj = 0;                         /* brightness adjustment */
47  
48   pic     *inpic, *outpic;
49  
# Line 78 | Line 82 | char  *argv[];
82                          case 'b':
83                                  greyscale = !greyscale;
84                                  break;
85 +                        case 'e':
86 +                                if (argv[i+1][0] != '+' && argv[i+1][0] != '-')
87 +                                        goto userr;
88 +                                bradj = atoi(argv[++i]);
89 +                                break;
90                          case 'r':
91                                  reverse = !reverse;
92                                  break;
# Line 116 | Line 125 | char  *argv[];
125                  printargs(i, argv, stdout);
126                  fputformat(COLRFMT, stdout);
127                  putchar('\n');
128 <                fputresolu(YMAJOR|YDECR, xmax, ymax, stdout);
128 >                fprtresolu(xmax, ymax, stdout);
129                                          /* convert file */
130                  pr2ra(&head);
131          } else {
132 <                if (i > argc-1 || i < argc-2)
132 >                if (i < argc-2 || (!greyscale && i > argc-1))
133                          goto userr;
134                  if ((inpic = openinput(argv[i], &head)) == NULL) {
135                          sprintf(errmsg, "can't open input \"%s\"", argv[i]);
# Line 140 | Line 149 | char  *argv[];
149          quiterr(NULL);
150   userr:
151          fprintf(stderr,
152 <        "Usage: %s [-d][-c ncolors][-b][-g gamma] input [output]\n",
152 >        "Usage: %s [-d][-c ncolors][-b][-g gamma][-e +/-stops] input [output]\n",
153                          progname);
154 <        fprintf(stderr, "   Or: %s -r [-g gamma] [input [output]]\n",
154 >        fprintf(stderr, "   Or: %s -r [-g gamma][-e +/-stops] [input [output]]\n",
155                          progname);
156          exit(1);
157   }
# Line 188 | Line 197 | register struct rasterfile  *h;
197                  return(NULL);
198                                          /* check header */
199          if (checkheader(p->fp, COLRFMT, NULL) < 0 ||
200 <                        fgetresolu(&xmax, &ymax, p->fp) != (YMAJOR|YDECR))
200 >                        fgetresolu(&xmax, &ymax, p->fp) < 0)
201                  quiterr("bad picture format");
202          p->nexty = 0;
203          p->bytes_line = 0;              /* variable length lines */
# Line 252 | Line 261 | struct rasterfile  *h;
261                                  pow((cmap[0][i]+.5)/256.,gamma),
262                                  pow((cmap[1][i]+.5)/256.,gamma),
263                                  pow((cmap[2][i]+.5)/256.,gamma));
264 +        if (bradj)
265 +                shiftcolrs(ctab, 256, bradj);
266                                          /* convert file */
267          for (i = 0; i < ymax; i++) {
268                  for (j = 0; j < xmax; j++) {
# Line 292 | Line 303 | register rgbpixel  *l3;
303                  quiterr("read error in picreadline3");
304          inpic->nexty = y+1;
305                                                          /* convert scanline */
306 <        normcolrs(inl, xmax, 0);
306 >        normcolrs(inl, xmax, bradj);
307          for (i = 0; i < xmax; i++) {
308                  l3[i].r = inl[i][RED];
309                  l3[i].g = inl[i][GRN];

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines