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.4 by greg, Thu Dec 19 14:52:09 1991 UTC vs.
Revision 2.8 by greg, Sat Feb 22 02:07:27 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 <math.h>
21 + #ifdef MSDOS
22 + #include <fcntl.h>
23 + #endif
24 + #include  <time.h>
25  
26   #include "pict.h"
27   #include "color.h"
28   #include "resolu.h"
29  
28 extern char     *malloc();
29
30   int     outbytes;                   /* This had better be 32 bits! */
31   char    *progname;
32   int     verbose = 0;
33 < float   gamma = 2.0;
33 > float   gamcor = 2.0;
34   int     bradj = 0;
35  
36          /* First some utility routines */
# Line 97 | Line 97 | char **argv;
97      int xsize, ysize;
98      int i, picsize;
99      int ssizepos, lsizepos;
100 <
100 > #ifdef MSDOS
101 >    extern int  _fmode;
102 >    _fmode = O_BINARY;
103 >    setmode(fileno(stdin), O_BINARY);
104 >    setmode(fileno(stdout), O_BINARY);
105 > #endif
106      progname = argv[0];
107  
108      for (i = 1; i < argc ; i++)
109 <        if (argv[i][0] ==  '-')
109 >        if (argv[i][0] ==  '-')
110              switch (argv[i][1]) {
111 <                case 'g':       gamma = atof(argv[++i]);
111 >                case 'g':       gamcor = atof(argv[++i]);
112                                  break;
113  
114                  case 'e':       if (argv[i+1][0] != '+' && argv[i+1][0] != '-')
# Line 148 | Line 153 | outofparse:
153          
154   #ifdef DEBUG
155          fprintf(stderr, "Input file: %s\n", i <= argc - 1 ? argv[i] : "stdin");
156 <        fprintf(stderr, "Outut file: %s\n", i <= argc - 2 ? argv[i+1] : "stdout" );
157 <        fprintf(stderr, "Gamma: %f\n", gamma);
156 >        fprintf(stderr, "Outut file: %s\n", i <= argc - 2 ? argv[i+1] : "stdout" );
157 >        fprintf(stderr, "Gamma: %f\n", gamcor);
158          fprintf(stderr, "Brightness adjust: %d\n", bradj);
159 <        fprintf(stderr, "Verbose: %s\n", verbose ? "on" : "off");
159 >        fprintf(stderr, "Verbose: %s\n", verbose ? "on" : "off");
160   #endif
161  
162  
163 <             /* OK. Now we read the size of the Radiance picture */
163 >             /* OK. Now we read the size of the Radiance picture */
164      if (checkheader(stdin, COLRFMT, NULL) < 0 ||
165 <            fgetresolu(&xsize, &ysize, stdin) < 0 /* != (YMAJOR|YDECR) */ ) {
166 <        fprintf(stderr, "%s: not a radiance picture\n", progname);
167 <        exit(1);
165 >            fgetresolu(&xsize, &ysize, stdin) < 0 /* != (YMAJOR|YDECR) */ ) {
166 >        fprintf(stderr, "%s: not a radiance picture\n", progname);
167 >        exit(1);
168          }
169  
170              /* Set the gamma correction */
171  
172 <    setcolrgam(gamma);
172 >    setcolrgam(gamcor);
173  
174      for(i=0; i<HEADER_SIZE; i++)
175          putbyte(0);
176  
177      ssizepos = outbytes;
178 <    putashort(0);               /* low 16 bits of file size less HEADER_SIZE */
178 >    putashort(0);               /* low 16 bits of file size less HEADER_SIZE */
179      putrect(0,0,xsize,ysize);   /* bounding box of picture */
180      putashort(PICT_picVersion);
181      putashort(0x02ff);          /* version 2 pict */
182      putashort(PICT_reservedHeader);     /* reserved header opcode */
183  
184      lsizepos = outbytes;
185 <    putalong(0);                /* full size of the file */
186 <    putfprect(0,0,xsize,ysize); /* fixed point bounding box of picture */
187 <    putalong(0);                /* reserved */
185 >    putalong(0);                /* full size of the file */
186 >    putfprect(0,0,xsize,ysize); /* fixed point bounding box of picture */
187 >    putalong(0);                /* reserved */
188  
189 <    putashort(PICT_clipRgn);    /* the clip region */
189 >    putashort(PICT_clipRgn);    /* the clip region */
190      putashort(10);
191      putrect(0,0,xsize,ysize);
192  
193      if (verbose)
194          fprintf(stderr, "%s: The picture is %d by %d, with a gamma of %f\n",
195 <            progname, xsize, ysize, gamma);
195 >            progname, xsize, ysize, gamcor);
196  
197  
198      putpict(xsize, ysize);      /* Here is where all the work is done */
# Line 215 | Line 220 | int ysize;
220      int     nbytes, rowbytes;
221      char    *cbuf, *pbuf;
222  
223 <    cbuf = malloc(4 * xsize);
223 >    cbuf = (char *)malloc(4 * xsize);
224  
225      if (cbuf == NULL) {
226          fprintf(stderr, "%s: not enough memory\n", progname);
227          exit(1);
228          }
229  
230 <    pbuf = malloc(4 * xsize);
230 >    pbuf = (char *)malloc(4 * xsize);
231  
232      if (pbuf == NULL) {
233          fprintf(stderr, "%s: not enough memory\n", progname);
# Line 236 | Line 241 | int ysize;
241  
242      if(rowbytes&1)
243          rowbytes++;
244 <    putashort(rowbytes|0x8000); /* rowbytes */
244 >    putashort(rowbytes|0x8000); /* rowbytes */
245      putrect(0,0,xsize,ysize);   /* bounds */
246      putashort(0);               /* version */
247  
# Line 285 | Line 290 | FILE *in;
290   char *cbuf;
291   int xsize;
292   {
293 <    extern char *tempbuffer();          /* defined in color.c */
293 >    extern char *tempbuffer();          /* defined in color.c */
294      COLR    *scanin = NULL;
295      int     x;
296  
# Line 295 | Line 300 | int xsize;
300      }
301  
302      if (freadcolrs(scanin, xsize, in) < 0) {
303 <        fprintf(stderr, "%s: read error\n", progname);
304 <        exit(1);
305 <        }
303 >        fprintf(stderr, "%s: read error\n", progname);
304 >        exit(1);
305 >        }
306  
307      if (bradj)      /* Adjust exposure level */
308          shiftcolrs(scanin, xsize, bradj);
# Line 331 | Line 336 | int nbits;
336          ibits += 2;
337          while((ibits<ibitsend)&&((ibits[-2]!=ibits[-1])||(ibits[-1]!=ibits[0])))
338              ibits++;
339 <        if(ibits != ibitsend) {
339 >        if(ibits != ibitsend) {
340              ibits -= 2;
341          }
342          count = ibits-sptr;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines