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

Comparing ray/src/px/ra_t16.c (file contents):
Revision 1.10 by greg, Wed Dec 12 14:40:07 1990 UTC vs.
Revision 2.1 by greg, Tue Nov 12 16:04:21 1991 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 15 | Line 15 | static char SCCSid[] = "$SunId$ LBL";
15  
16   #include  "color.h"
17  
18 + #include  "resolu.h"
19 +
20   #include  "random.h"
21  
22   #include  "targa.h"
# Line 34 | Line 36 | extern char    *ecalloc(), *emalloc();
36  
37   extern double  atof(), pow();
38  
39 < double  gamma = 2.0;                    /* gamma correction */
39 > double  gamma = 2.2;                    /* gamma correction */
40  
41 + int  bradj = 0;                         /* brightness adjustment */
42 +
43   char  *progname;
44  
45   char  msg[128];
# Line 67 | Line 71 | char  *argv[];
71                          case '3':
72                                  head.dataBits = 24;
73                                  break;
74 +                        case 'e':
75 +                                if (argv[i+1][0] != '+' && argv[i+1][0] != '-')
76 +                                        goto userr;
77 +                                bradj = atoi(argv[++i]);
78 +                                break;
79                          default:
80                                  goto userr;
81                          }
# Line 96 | Line 105 | char  *argv[];
105                          quiterr("incompatible format");
106                                          /* put header */
107                  printargs(i, argv, stdout);
108 +                fputformat(COLRFMT, stdout);
109                  putchar('\n');
110 <                fputresolu(YMAJOR|YDECR, head.x, head.y, stdout);
110 >                fprtresolu(head.x, head.y, stdout);
111                                          /* convert file */
112                  tg2ra(&head);
113          } else {
114 <                getheader(stdin, NULL);
115 <                if (fgetresolu(&head.x, &head.y, stdin) != (YMAJOR|YDECR))
114 >                if (checkheader(stdin, COLRFMT, NULL) < 0 ||
115 >                                fgetresolu(&head.x, &head.y, stdin) < 0)
116                          quiterr("bad picture file");
117                                          /* assign header */
118                  head.textSize = 0;
# Line 118 | Line 128 | char  *argv[];
128          }
129          exit(0);
130   userr:
131 <        fprintf(stderr, "Usage: %s [-2|-3|-r][-g gamma] [input [output]]\n",
131 >        fprintf(stderr, "Usage: %s [-2|-3|-r][-g gamma][-e +/-stops] [input [output]]\n",
132                          progname);
133          exit(1);
134   }
# Line 266 | Line 276 | struct hdStruct  *hp;
276                          }
277                  }
278                  gambs_colrs(scanline, hp->x);
279 +                if (bradj)
280 +                        shiftcolrs(scanline, hp->x, bradj);
281                  if (fwritecolrs(scanline, hp->x, stdout) < 0)
282                          quiterr("error writing RADIANCE file");
283          }
# Line 287 | Line 299 | struct hdStruct  *hp;
299          for (j = hp->y-1; j >= 0; j--) {
300                  if (freadcolrs(inl, hp->x, stdin) < 0)
301                          quiterr("error reading RADIANCE file");
302 +                if (bradj)
303 +                        shiftcolrs(inl, hp->x, bradj);
304                  colrs_gambs(inl, hp->x);
305                  if (hp->dataBits == 16) {
306                          register unsigned short  *dp;
307 +                        register int  v;
308                          dp = (unsigned short *)tarData + j*hp->x;
309                          for (i = 0; i < hp->x; i++) {
310 <                                *dp = ((inl[i][RED]+(random()&7)) & 0xf8)<<7;
311 <                                *dp |= ((inl[i][GRN]+(random()&7)) & 0xf8)<<2;
312 <                                *dp++ |= (inl[i][BLU]+(random()&7))>>3;
310 >                                v = inl[i][RED] + (random()&7);
311 >                                if (v > 255) v = 255;
312 >                                *dp = (v&0xf8)<<7;
313 >                                v = inl[i][GRN] + (random()&7);
314 >                                if (v > 255) v = 255;
315 >                                *dp |= (v&0xf8)<<2;
316 >                                v = inl[i][BLU] + (random()&7);
317 >                                if (v > 255) v = 255;
318 >                                *dp++ |= v>>3;
319                          }
320                  } else {        /* hp->dataBits == 24 */
321                          register unsigned char  *dp;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines