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.22 by gwlarson, Tue Oct 27 09:08:27 1998 UTC vs.
Revision 2.27 by schorsch, Fri Jan 2 12:47:01 2004 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   */
7  
8   #include  <stdio.h>
9 + #include  <string.h>
10   #include  <math.h>
11   #include  <ctype.h>
12 < #ifdef MSDOS
13 < #include  <fcntl.h>
16 < #endif
12 >
13 > #include  "platform.h"
14   #include  "color.h"
15 + #include  "resolu.h"
16  
17   #define UPPER(c)        ((c)&~0x20)             /* ASCII trick */
18  
# Line 61 | Line 59 | char  *progname;
59  
60   int  xmax, ymax;                        /* input image dimensions */
61  
64 extern char  *malloc();
62   extern double   unit2inch();
63  
64 + static gethfunc headline;
65  
66 < int
67 < headline(s)             /* check header line */
68 < char  *s;
66 >
67 > static int
68 > headline(               /* check header line */
69 >        char    *s,
70 >        void    *p
71 > )
72   {
73          char  fmt[32];
74  
# Line 160 | Line 161 | char  *argv[];
161                                  progname, argv[i+1]);
162                  exit(1);
163          }
164 < #ifdef MSDOS
164 <        setmode(fileno(stdin), O_BINARY);
165 < #endif
164 >        SET_FILE_BINARY(stdin);
165                                  /* get our header */
166          getheader(stdin, headline, NULL);
167          if (wrongformat || fgetresolu(&xmax, &ymax, stdin) < 0)
# Line 193 | Line 192 | double
192   unit2inch(s)            /* determine unit */
193   register char   *s;
194   {
195 <        static struct unit {char n; float f} u[] = {
196 <                'i', 1.,
197 <                'm', 1./25.4,
198 <                'c', 1./2.54,
199 <                '\0' };
195 >        static struct unit {char n; float f;} u[] = {
196 >                {'i', 1.},
197 >                {'m', 1./25.4},
198 >                {'c', 1./2.54},
199 >                {'\0',0} };
200          register struct unit    *up;
201  
202          while (*s && !isalpha(*s))
# Line 232 | Line 231 | parsepaper(ps)         /* determine paper size from name */
231   char    *ps;
232   {
233          static struct psize {char n[12]; float w,h;} p[] = {
234 <                "envelope", 4.12, 9.5,
235 <                "executive", 7.25, 10.5,
236 <                "letter", 8.5, 11.,
237 <                "lettersmall", 7.68, 10.16,
238 <                "legal", 8.5, 14.,
239 <                "monarch", 3.87, 7.5,
240 <                "statement", 5.5, 8.5,
241 <                "tabloid", 11., 17.,
242 <                "A3", 11.69, 16.54,
243 <                "A4", 8.27, 11.69,
244 <                "A4small", 7.47, 10.85,
245 <                "A5", 6.00, 8.27,
246 <                "A6", 4.13, 6.00,
247 <                "B4", 10.12, 14.33,
248 <                "B5", 7.17, 10.12,
249 <                "C5", 6.38, 9.01,
250 <                "C6", 4.49, 6.38,
251 <                "DL", 4.33, 8.66,
252 <                "hagaki", 3.94, 5.83,
253 <                "" };
234 >                {"envelope", 4.12, 9.5},
235 >                {"executive", 7.25, 10.5},
236 >                {"letter", 8.5, 11.},
237 >                {"lettersmall", 7.68, 10.16},
238 >                {"legal", 8.5, 14.},
239 >                {"monarch", 3.87, 7.5},
240 >                {"statement", 5.5, 8.5},
241 >                {"tabloid", 11., 17.},
242 >                {"A3", 11.69, 16.54},
243 >                {"A4", 8.27, 11.69},
244 >                {"A4small", 7.47, 10.85},
245 >                {"A5", 6.00, 8.27},
246 >                {"A6", 4.13, 6.00},
247 >                {"B4", 10.12, 14.33},
248 >                {"B5", 7.17, 10.12},
249 >                {"C5", 6.38, 9.01},
250 >                {"C6", 4.49, 6.38},
251 >                {"DL", 4.33, 8.66},
252 >                {"hagaki", 3.94, 5.83},
253 >                {"",0.0,0.0} };
254          register struct psize   *pp;
255          register char   *s = ps;
256          double  d;
# Line 264 | Line 263 | char   *ps;
263                  height = atof(++s);
264                  width *= d;
265                  height *= d;
266 <                if (width >= 1. & height >= 1.)
266 >                if ((width >= 1.) & (height >= 1.))
267                          return;
268          } else                          /* check for match to standard size */
269                  for (pp = p; pp->n[0]; pp++)
# Line 305 | Line 304 | char  **av;
304                                          /* EPS comments */
305          puts("%!PS-Adobe-2.0 EPSF-2.0");
306          printf("%%%%Title: "); printargs(ac, av, stdout);
307 <        printf("%%%%Creator: %s\n", SCCSid);
307 >        printf("%%%%Creator: %s\n", progname);
308          printf("%%%%Pages: %d\n", ncopies);
309 <        if (landscape = xmax > pixaspect*ymax)
309 >        if ( (landscape = xmax > pixaspect*ymax) )
310                  puts("%%Orientation: Landscape");
311          else
312                  puts("%%Orientation: Portrait");
313 <        if (rotate = PWIDTH > PHEIGHT ^ landscape) {
313 >        if ( (rotate = (PWIDTH > PHEIGHT) ^ landscape) ) {
314                  pwidth = PHEIGHT;
315                  pheight = PWIDTH;
316          } else {
317                  pwidth = PWIDTH;
318                  pheight = PHEIGHT;
319          }
320 <        if (dpi > 100 && pixaspect >= 0.99 & pixaspect <= 1.01)
320 >        if (dpi > 100 && (pixaspect >= 0.99) & (pixaspect <= 1.01))
321                  if (pheight/pwidth > ymax/xmax) {
322                          n = pwidth*dpi/xmax;    /* floor */
323                          iwidth = n > 0 ? (double)(n*xmax)/dpi : pwidth;
# Line 474 | Line 473 | ra2ps()                                /* convert Radiance scanlines to 6-bit */
473          }
474          putchar('\n');
475                                                  /* free scanline */
476 <        free((char *)scanin);
476 >        free((void *)scanin);
477   }
478  
479  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines