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

Comparing ray/src/px/ra_pict.c (file contents):
Revision 2.2 by greg, Thu Nov 21 11:34:10 1991 UTC vs.
Revision 2.9 by schorsch, Thu Jun 5 19:29:34 2003 UTC

# Line 1 | Line 1
1   #ifndef lint
2 < static char SCCSid[] = "$SunId$ Auckuni";
2 > static const char       RCSid[] = "$Id$";
3   #endif
4 <
5 < /*
6 < *      rad2pict -
7 < *              Convert an Radiance image to APPLE pict format.
4 > /*              Convert an Radiance image to APPLE pict format.
5   *
6   *                      Orginally Iris to PICT by       Paul Haeberli - 1990
7   *                      Hacked into Rad to PICT by Russell Street 1990
# Line 20 | Line 17 | static char SCCSid[] = "$SunId$ Auckuni";
17   */
18  
19   #include <stdio.h>
20 < #include <stdlib.h>
20 > #include <math.h>
21 > #include  <time.h>
22  
23 + #include "platform.h"
24   #include "pict.h"
25   #include "color.h"
26   #include "resolu.h"
# Line 29 | Line 28 | static char SCCSid[] = "$SunId$ Auckuni";
28   int     outbytes;                   /* This had better be 32 bits! */
29   char    *progname;
30   int     verbose = 0;
31 < float   gamma = 2.0;
31 > float   gamcor = 2.0;
32   int     bradj = 0;
33  
34          /* First some utility routines */
# Line 96 | Line 95 | char **argv;
95      int xsize, ysize;
96      int i, picsize;
97      int ssizepos, lsizepos;
98 <
98 >        SET_DEFAULT_BINARY();
99 >    SET_FILE_BINARY(stdin);
100 >    SET_FILE_BINARY(stdout);
101      progname = argv[0];
102  
103      for (i = 1; i < argc ; i++)
104 <        if (argv[i][0] ==  '-')
104 >        if (argv[i][0] ==  '-')
105              switch (argv[i][1]) {
106 <                case 'g':       gamma = atof(argv[++i]);
106 >                case 'g':       gamcor = atof(argv[++i]);
107                                  break;
108  
109                  case 'e':       if (argv[i+1][0] != '+' && argv[i+1][0] != '-')
# Line 147 | Line 148 | outofparse:
148          
149   #ifdef DEBUG
150          fprintf(stderr, "Input file: %s\n", i <= argc - 1 ? argv[i] : "stdin");
151 <        fprintf(stderr, "Outut file: %s\n", i <= argc - 2 ? argv[i+1] : "stdout" );
152 <        fprintf(stderr, "Gamma: %f\n", gamma);
151 >        fprintf(stderr, "Outut file: %s\n", i <= argc - 2 ? argv[i+1] : "stdout" );
152 >        fprintf(stderr, "Gamma: %f\n", gamcor);
153          fprintf(stderr, "Brightness adjust: %d\n", bradj);
154 <        fprintf(stderr, "Verbose: %s\n", verbose ? "on" : "off");
154 >        fprintf(stderr, "Verbose: %s\n", verbose ? "on" : "off");
155   #endif
156  
157  
158 <             /* OK. Now we read the size of the Radiance picture */
158 >             /* OK. Now we read the size of the Radiance picture */
159      if (checkheader(stdin, COLRFMT, NULL) < 0 ||
160 <            fgetresolu(&xsize, &ysize, stdin) < 0 /* != (YMAJOR|YDECR) */ ) {
161 <        fprintf(stderr, "%s: not a radiance picture\n", progname);
162 <        exit(1);
160 >            fgetresolu(&xsize, &ysize, stdin) < 0 /* != (YMAJOR|YDECR) */ ) {
161 >        fprintf(stderr, "%s: not a radiance picture\n", progname);
162 >        exit(1);
163          }
164  
165              /* Set the gamma correction */
166  
167 <    setcolrgam(gamma);
167 >    setcolrgam(gamcor);
168  
169      for(i=0; i<HEADER_SIZE; i++)
170          putbyte(0);
171  
172      ssizepos = outbytes;
173 <    putashort(0);               /* low 16 bits of file size less HEADER_SIZE */
173 >    putashort(0);               /* low 16 bits of file size less HEADER_SIZE */
174      putrect(0,0,xsize,ysize);   /* bounding box of picture */
175      putashort(PICT_picVersion);
176      putashort(0x02ff);          /* version 2 pict */
177      putashort(PICT_reservedHeader);     /* reserved header opcode */
178  
179      lsizepos = outbytes;
180 <    putalong(0);                /* full size of the file */
181 <    putfprect(0,0,xsize,ysize); /* fixed point bounding box of picture */
182 <    putalong(0);                /* reserved */
180 >    putalong(0);                /* full size of the file */
181 >    putfprect(0,0,xsize,ysize); /* fixed point bounding box of picture */
182 >    putalong(0);                /* reserved */
183  
184 <    putashort(PICT_clipRgn);    /* the clip region */
184 >    putashort(PICT_clipRgn);    /* the clip region */
185      putashort(10);
186      putrect(0,0,xsize,ysize);
187  
188      if (verbose)
189          fprintf(stderr, "%s: The picture is %d by %d, with a gamma of %f\n",
190 <            progname, xsize, ysize, gamma);
190 >            progname, xsize, ysize, gamcor);
191  
192  
193      putpict(xsize, ysize);      /* Here is where all the work is done */
# Line 214 | Line 215 | int ysize;
215      int     nbytes, rowbytes;
216      char    *cbuf, *pbuf;
217  
218 <    cbuf = malloc(4 * xsize);
218 >    cbuf = (char *)malloc(4 * xsize);
219  
220      if (cbuf == NULL) {
221          fprintf(stderr, "%s: not enough memory\n", progname);
222          exit(1);
223          }
224  
225 <    pbuf = malloc(4 * xsize);
225 >    pbuf = (char *)malloc(4 * xsize);
226  
227      if (pbuf == NULL) {
228          fprintf(stderr, "%s: not enough memory\n", progname);
# Line 235 | Line 236 | int ysize;
236  
237      if(rowbytes&1)
238          rowbytes++;
239 <    putashort(rowbytes|0x8000); /* rowbytes */
239 >    putashort(rowbytes|0x8000); /* rowbytes */
240      putrect(0,0,xsize,ysize);   /* bounds */
241      putashort(0);               /* version */
242  
# Line 284 | Line 285 | FILE *in;
285   char *cbuf;
286   int xsize;
287   {
288 <    extern char *tempbuffer();          /* defined in color.c */
288 >    extern char *tempbuffer();          /* defined in color.c */
289      COLR    *scanin = NULL;
290      int     x;
291  
# Line 294 | Line 295 | int xsize;
295      }
296  
297      if (freadcolrs(scanin, xsize, in) < 0) {
298 <        fprintf(stderr, "%s: read error\n", progname);
299 <        exit(1);
300 <        }
298 >        fprintf(stderr, "%s: read error\n", progname);
299 >        exit(1);
300 >        }
301  
302      if (bradj)      /* Adjust exposure level */
303          shiftcolrs(scanin, xsize, bradj);
# Line 330 | Line 331 | int nbits;
331          ibits += 2;
332          while((ibits<ibitsend)&&((ibits[-2]!=ibits[-1])||(ibits[-1]!=ibits[0])))
333              ibits++;
334 <        if(ibits != ibitsend) {
334 >        if(ibits != ibitsend) {
335              ibits -= 2;
336          }
337          count = ibits-sptr;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines