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.1 by greg, Mon Jul 13 09:28:01 1992 UTC vs.
Revision 2.5 by greg, Fri Aug 14 14:04:09 1992 UTC

# Line 4 | Line 4
4   static char SCCSid[] = "$SunId$ LBL";
5   #endif
6  
7 /* Copyright (c) 1992 Regents of the University of California */
8
9 #ifndef lint
10 static char SCCSid[] = "$SunId$ LBL";
11 #endif
12
7   /*
8   *  Radiance picture to PostScript file translator -- one way!
9   */
# Line 30 | Line 24 | int  wrongformat = 0;                  /* input in wrong format? */
24   double  pixaspect = 1.0;                /* pixel aspect ratio */
25  
26   int  bradj = 0;                         /* brightness adjustment */
27 + int  ncopies = 1;                       /* number of copies */
28  
29   char  *progname;
30  
# Line 65 | Line 60 | char  *argv[];
60                                          goto userr;
61                                  bradj = atoi(argv[++i]);
62                                  break;
63 +                        case 'n':               /* number of copies */
64 +                                ncopies = atoi(argv[++i]);
65 +                                break;
66                          default:
67                                  goto userr;
68                          }
# Line 116 | Line 114 | char  *name;
114   {
115          int  landscape = 0;
116          double  pwidth, pheight;
117 +        double  iwidth, iheight;
118  
119          printf("%%!\n");
120          printf("%%%%Title: %s\n", name);
121          printf("%%%%Creator: %s\n", progname);
122 <        printf("%%%%Pages: 1\n");
122 >        printf("%%%%Pages: %d\n", ncopies);
123          if (landscape = xmax > pixaspect*ymax)
124                  printf("%%%%Landscape\n");
125          else
126                  printf("%%%%Portrait\n");
127          printf("%%%%EndComments\n");
129        printf("gsave\n");
128          printf("64 dict begin\n");
129 +                                        /* define image reader */
130 +        PSprocdef("read6bit");
131                                          /* set up transformation matrix */
132 <        printf("%f %f translate 1 -1 scale\n", HMARGIN, VMARGIN+PHEIGHT);
132 >        printf("%f %f translate\n", HMARGIN, VMARGIN);
133          if (PWIDTH > PHEIGHT ^ landscape) {
134                  printf("0 %f translate\n", PHEIGHT);
135 <                printf("90 rotate\n");
135 >                printf("-90 rotate\n");
136                  pwidth = PHEIGHT;
137                  pheight = PWIDTH;
138          } else {
# Line 140 | Line 140 | char  *name;
140                  pheight = PHEIGHT;
141          }
142          if (pheight/pwidth > pixaspect*ymax/xmax) {
143 <                printf("%f %f matrix scale\n", pwidth/xmax,
144 <                                pixaspect*pwidth/xmax);
145 <                printf("0 %f matrix translate\n",
146 <                                .5*(pheight-pwidth*pixaspect*ymax/xmax));
143 >                iwidth = pwidth;
144 >                iheight = pwidth*pixaspect*ymax/xmax;
145          } else {
146 <                printf("%f %f matrix scale\n", pheight/(ymax*pixaspect),
147 <                                pheight/ymax);
150 <                printf("%f 0 matrix translate\n",
151 <                                .5*(pwidth-pheight*xmax/(ymax*pixaspect)));
146 >                iheight = pheight;
147 >                iwidth = pheight*xmax/(pixaspect*ymax);
148          }
149 <        printf("matrix concatmatrix /imat exch def\n");
150 <        PSprocdef("read6bit");
149 >        printf("%f %f translate\n", (pwidth-iwidth)*.5, (pheight-iheight)*.5);
150 >        printf("%f %f scale\n", iwidth, iheight);
151          printf("%%%%EndProlog\n");
152 <        printf("%d %d 8 imat {read6bit} image", xmax, ymax);
152 >                                        /* start image procedure */
153 >        printf("%d %d 8 [%d 0 0 %d 0 %d] {read6bit} image", xmax, ymax,
154 >                        xmax, -ymax, ymax);
155   }
156  
157  
158   PStrailer()                     /* print PostScript trailer */
159   {
160          puts("%%Trailer");
161 <        puts("end");
161 >        if (ncopies > 1)
162 >                printf("/#copies %d def\n", ncopies);
163          puts("showpage");
164 <        puts("grestore");
164 >        puts("end");
165          puts("%%EOF");
166   }
167  
# Line 172 | Line 171 | char  *nam;
171   {
172          short  itab[128];
173          register int  i;
174 <        
175 <        for (i = 0; i < 128; i++)
174 >                                /* assign code values */
175 >        for (i = 0; i < 128; i++)       /* clear */
176                  itab[i] = -1;
177 <        for (i = 0; i < 64; i++)
177 >        for (i = 1; i < 63; i++)        /* assign greys */
178                  itab[code[i]] = i<<2 | 2;
179 +        itab[code[0]] = 0;              /* black is black */
180 +        itab[code[63]] = 255;           /* and white is white */
181          printf("/decode [");
182          for (i = 0; i < 128; i++) {
183                  if (!(i & 0xf))

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines