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.20 by gregl, Fri Sep 26 14:20:38 1997 UTC vs.
Revision 2.25 by schorsch, Thu Jun 5 19:29:34 2003 UTC

# Line 1 | Line 1
1 /* Copyright (c) 1997 Silicon Graphics, Inc. */
2
1   #ifndef lint
2 < static char SCCSid[] = "$SunId$ SGI";
2 > static const char       RCSid[] = "$Id$";
3   #endif
6
4   /*
5   *  Radiance picture to PostScript file translator -- one way!
6   */
# Line 11 | Line 8 | static char SCCSid[] = "$SunId$ SGI";
8   #include  <stdio.h>
9   #include  <math.h>
10   #include  <ctype.h>
11 < #ifdef MSDOS
12 < #include  <fcntl.h>
16 < #endif
11 >
12 > #include  "platform.h"
13   #include  "color.h"
14  
15   #define UPPER(c)        ((c)&~0x20)             /* ASCII trick */
16  
17   #define CODE6GAM        1.47                    /* gamma for 6-bit codes */
18 < #define DEFDGAM         1.0                     /* default device gamma */
18 > #define DEFGGAM         1.0                     /* greyscale device gamma */
19 > #define DEFCGAM         1.8                     /* color device gamma */
20  
21   #define GRY             -1                      /* artificial index for grey */
22  
# Line 42 | Line 39 | char  code[] =                 /* 6-bit code lookup table */
39   int  wrongformat = 0;                   /* input in wrong format? */
40   double  pixaspect = 1.0;                /* pixel aspect ratio */
41  
42 < double  devgam = DEFDGAM;               /* device gamma response */
42 > double  devgam = 0.;                    /* device gamma response */
43   double  hmarg = DEFMARG,
44          vmarg = DEFMARG;                /* horizontal and vertical margins */
45   double  width = DEFWIDTH,
46          height = DEFHEIGHT;             /* default paper width and height */
47   double  dpi = 0;                        /* print density (0 if unknown) */
48 < int  docolor = 0;                       /* produce color image? */
48 > int  docolor = 1;                       /* produce color image? */
49   int  bradj = 0;                         /* brightness adjustment */
50   int  ncopies = 1;                       /* number of copies */
51  
# Line 60 | Line 57 | char  *progname;
57  
58   int  xmax, ymax;                        /* input image dimensions */
59  
63 extern char  *malloc();
60   extern double   unit2inch();
61  
62  
63 + int
64   headline(s)             /* check header line */
65   char  *s;
66   {
# Line 74 | Line 71 | char  *s;
71                  wrongformat = strcmp(fmt, COLRFMT);
72          } else if (isaspect(s))
73                  pixaspect *= aspectval(s);
74 +        return(0);
75   }
76  
77  
# Line 157 | Line 155 | char  *argv[];
155                                  progname, argv[i+1]);
156                  exit(1);
157          }
158 < #ifdef MSDOS
161 <        setmode(fileno(stdin), O_BINARY);
162 < #endif
158 >        SET_FILE_BINARY(stdin);
159                                  /* get our header */
160          getheader(stdin, headline, NULL);
161          if (wrongformat || fgetresolu(&xmax, &ymax, stdin) < 0)
162                  quiterr("bad picture format");
163                                  /* gamma compression */
164 +        if (devgam <= 0.05)
165 +                devgam = docolor ? DEFCGAM : DEFGGAM;
166          if (putprim == Cputprim)
167                  setcolrgam(CODE6GAM);
168          else if (devgam != 1.)
169                  setcolrgam(devgam);
170                                  /* write header */
171 <        PSheader(i <= argc-1 ? argv[i] : "<stdin>");
171 >        PSheader(argc, argv);
172                                  /* convert file */
173          ra2ps();
174                                  /* write trailer */
# Line 188 | Line 186 | double
186   unit2inch(s)            /* determine unit */
187   register char   *s;
188   {
189 <        static struct unit {char n; float f} u[] = {
189 >        static struct unit {char n; float f;} u[] = {
190                  'i', 1.,
191                  'm', 1./25.4,
192                  'c', 1./2.54,
# Line 289 | Line 287 | char  *err;
287   }
288  
289  
290 < PSheader(name)                  /* print PostScript header */
291 < char  *name;
290 > PSheader(ac, av)                /* print PostScript header */
291 > int  ac;
292 > char  **av;
293   {
294          char  *rstr;
295          int  landscape, rotate, n;
# Line 298 | Line 297 | char  *name;
297          double  iwidth, iheight;
298                                          /* EPS comments */
299          puts("%!PS-Adobe-2.0 EPSF-2.0");
300 <        printf("%%%%Title: %s\n", name);
301 <        printf("%%%%Creator: %s = %s\n", progname, SCCSid);
300 >        printf("%%%%Title: "); printargs(ac, av, stdout);
301 >        printf("%%%%Creator: %s\n", progname);
302          printf("%%%%Pages: %d\n", ncopies);
303          if (landscape = xmax > pixaspect*ymax)
304                  puts("%%Orientation: Landscape");
# Line 468 | Line 467 | ra2ps()                                /* convert Radiance scanlines to 6-bit */
467          }
468          putchar('\n');
469                                                  /* free scanline */
470 <        free((char *)scanin);
470 >        free((void *)scanin);
471   }
472  
473  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines