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.19 by gregl, Tue Sep 23 16:52:23 1997 UTC vs.
Revision 2.20 by gregl, Fri Sep 26 14:20:38 1997 UTC

# Line 47 | Line 47 | double  hmarg = DEFMARG,
47          vmarg = DEFMARG;                /* horizontal and vertical margins */
48   double  width = DEFWIDTH,
49          height = DEFHEIGHT;             /* default paper width and height */
50 + double  dpi = 0;                        /* print density (0 if unknown) */
51   int  docolor = 0;                       /* produce color image? */
52   int  bradj = 0;                         /* brightness adjustment */
53   int  ncopies = 1;                       /* number of copies */
# Line 57 | Line 58 | int  (*putprim)() = Aputprim;          /* function for writing
58  
59   char  *progname;
60  
61 < int  xmax, ymax;
61 > int  xmax, ymax;                        /* input image dimensions */
62  
63   extern char  *malloc();
64   extern double   unit2inch();
# Line 103 | Line 104 | char  *argv[];
104                          case 'C':               /* compressed ASCII encoding */
105                                  putprim = Cputprim;
106                                  break;
107 +                        case 'd':               /* print density */
108 +                                dpi = atof(argv[++i]);
109 +                                break;
110                          case 'g':               /* device gamma adjustment */
111                                  devgam = atof(argv[++i]);
112                                  break;
# Line 174 | Line 178 | char  *argv[];
178          exit(0);
179   userr:
180          fprintf(stderr,
181 < "Usage: %s [-b|c][-A|B|C][-e +/-stops][-p paper][-m[h|v] margin][-g gamma] [input [output]]\n",
181 > "Usage: %s [-b|c][-A|B|C][-e +/-stops][-p paper][-m[h|v] margin][-d dpi][-g gamma] [input [output]]\n",
182                          progname);
183          exit(1);
184   }
# Line 289 | Line 293 | PSheader(name)                 /* print PostScript header */
293   char  *name;
294   {
295          char  *rstr;
296 <        int  landscape = 0;
296 >        int  landscape, rotate, n;
297          double  pwidth, pheight;
298          double  iwidth, iheight;
299                                          /* EPS comments */
# Line 301 | Line 305 | char  *name;
305                  puts("%%Orientation: Landscape");
306          else
307                  puts("%%Orientation: Portrait");
308 <        if (PWIDTH > PHEIGHT ^ landscape) {
308 >        if (rotate = PWIDTH > PHEIGHT ^ landscape) {
309                  pwidth = PHEIGHT;
310                  pheight = PWIDTH;
311          } else {
312                  pwidth = PWIDTH;
313                  pheight = PHEIGHT;
314          }
315 <        if (pheight/pwidth > pixaspect*ymax/xmax) {
316 <                iwidth = pwidth;
317 <                iheight = pwidth*pixaspect*ymax/xmax;
318 <        } else {
319 <                iheight = pheight;
320 <                iwidth = pheight*xmax/(pixaspect*ymax);
321 <        }
322 <        if (pwidth == PHEIGHT)
315 >        if (dpi > 100 && pixaspect >= 0.99 & pixaspect <= 1.01)
316 >                if (pheight/pwidth > ymax/xmax) {
317 >                        n = pwidth*dpi/xmax;    /* floor */
318 >                        iwidth = n > 0 ? (double)(n*xmax)/dpi : pwidth;
319 >                        iheight = iwidth*ymax/xmax;
320 >                } else {
321 >                        n = pheight*dpi/ymax;   /* floor */
322 >                        iheight = n > 0 ? (double)(n*ymax)/dpi : pheight;
323 >                        iwidth = iheight*xmax/ymax;
324 >                }
325 >        else
326 >                if (pheight/pwidth > pixaspect*ymax/xmax) {
327 >                        iwidth = pwidth;
328 >                        iheight = iwidth*pixaspect*ymax/xmax;
329 >                } else {
330 >                        iheight = pheight;
331 >                        iwidth = iheight*xmax/(pixaspect*ymax);
332 >                }
333 >        if (rotate)
334                  printf("%%%%BoundingBox: %.0f %.0f %.0f %.0f\n",
335                                  HMARGIN+(pheight-iheight)*.5,
336                                  VMARGIN+(pwidth-iwidth)*.5,
# Line 342 | Line 357 | char  *name;
357                  PSprocdef("read6bitRLE");
358                                          /* set up transformation matrix */
359          printf("%f %f translate\n", HMARGIN, VMARGIN);
360 <        if (pwidth == PHEIGHT) {
360 >        if (rotate) {
361                  printf("%f 0 translate\n", PWIDTH);
362                  puts("90 rotate");
363          }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines