ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/px/psign.c
(Generate patch)

Comparing ray/src/px/psign.c (file contents):
Revision 2.5 by greg, Tue Jun 16 16:27:37 1992 UTC vs.
Revision 2.16 by greg, Mon Feb 28 09:25:31 1994 UTC

# Line 1 | Line 1
1 < /* Copyright (c) 1991 Regents of the University of California */
1 > /* Copyright (c) 1992 Regents of the University of California */
2  
3   #ifndef lint
4   static char SCCSid[] = "$SunId$ LBL";
# Line 16 | Line 16 | static char SCCSid[] = "$SunId$ LBL";
16  
17   #include  "font.h"
18  
19 < #ifndef  SSS
20 < #define  SSS                    3       /* super-sample size */
21 < #endif
19 > #include  "paths.h"
20  
21 < #define  MAXLINE                512     /* longest allowable line */
22 <
25 < #ifndef  DEFPATH
26 < #define  DEFPATH                ":/usr/local/lib/ray"
21 > #ifndef  SSS
22 > #define  SSS                    3       /* super-sample size */
23   #endif
28 #ifndef  ULIBVAR
29 #define  ULIBVAR                "RAYPATH"
30 #endif
24  
25 + #define  MAXLINE                512     /* longest allowable line */
26 +
27   char  *fontfile = "helvet.fnt";         /* our font file */
28  
29   COLOR  bgcolor = WHTCOLOR;              /* background color */
# Line 37 | Line 32 | COLOR  fgcolor = BLKCOLOR;             /* foreground color */
32   int  direct = 'r';                      /* direction (right, up, left, down) */
33  
34   int  cheight = 32*SSS;                  /* character height */
35 < double  aspect = 1.67;                  /* height/width character aspect */
35 > double  aspect = 1.67;                  /* height/width character aspect */
36 > double  spacing = 0.0;                  /* character spacing */
37   int  cwidth;                            /* computed character width */
38  
39   unsigned char  *ourbitmap;              /* our output bitmap */
40   int  xsiz, ysiz;                        /* bitmap dimensions */
41   int  xdim;                              /* size of horizontal scan (bytes) */
42  
43 < #define  bitop(x,y,op)          (ourbitmap[(y)*xdim+((x)>>3)] op (1<<((x)&7)))
44 < #define  tstbit(x,y)            bitop(x,y,&)
45 < #define  setbit(x,y)            bitop(x,y,|=)
46 < #define  clrbit(x,y)            bitop(x,y,&=~)
47 < #define  tglbit(x,y)            bitop(x,y,^=)
43 > #define  bitop(x,y,op)          (ourbitmap[(y)*xdim+((x)>>3)] op (1<<((x)&7)))
44 > #define  tstbit(x,y)            bitop(x,y,&)
45 > #define  setbit(x,y)            bitop(x,y,|=)
46 > #define  clrbit(x,y)            bitop(x,y,&=~)
47 > #define  tglbit(x,y)            bitop(x,y,^=)
48  
49   FONT  *ourfont;                         /* our font */
50  
# Line 64 | Line 60 | LINE  *ourtext;                                /* our text */
60   int  nlines, maxline;                   /* text dimensions */
61   int  maxwidth;                          /* maximum line width (dvi) */
62  
67 extern char  *getenv();
68 extern char  *malloc(), *calloc();
63  
70
64   main(argc, argv)
65   int  argc;
66   char  *argv[];
67   {
68          int  an;
69 <
69 > #ifdef MSDOS
70 >        setmode(fileno(stdout), O_BINARY);
71 > #endif
72          for (an = 1; an < argc && argv[an][0] == '-'; an++)
73                  switch (argv[an][1]) {
74                  case 'c':                       /* color */
# Line 109 | Line 104 | char  *argv[];
104                                  goto unkopt;
105                          }
106                          break;
107 +                case 'x':                       /* x resolution */
108 +                        xsiz = atoi(argv[++an])*SSS;
109 +                        break;
110 +                case 'y':
111 +                        ysiz = atoi(argv[++an])*SSS;
112 +                        break;
113                  case 'h':                       /* height of characters */
114                          cheight = atoi(argv[++an])*SSS;
115                          break;
116                  case 'a':                       /* aspect ratio */
117                          aspect = atof(argv[++an]);
118                          break;
119 +                case 's':                       /* spacing */
120 +                        spacing = atof(argv[++an]);
121 +                        break;
122                  default:;
123   unkopt:
124                          fprintf(stderr, "%s: unknown option: %s\n",
# Line 136 | Line 140 | unkopt:
140                                          /* convert text to bitmap */
141          maptext();
142                                          /* print header */
143 +        newheader("RADIANCE", stdout);
144          printargs(argc, argv, stdout);
145          fputformat(COLRFMT, stdout);
146          putchar('\n');
# Line 148 | Line 153 | unkopt:
153  
154   makemap()                       /* create the bit map */
155   {
156 <        cwidth = cheight/aspect + 0.5;
156 >        double  pictaspect;
157 >        
158          if (direct == 'r' || direct == 'l') {
159 <                xsiz = (long)maxwidth*cwidth >> 8;
160 <                ysiz = nlines*cheight;
159 >                if (xsiz <= 0) {
160 >                        cwidth = cheight/aspect + 0.5;
161 >                        xsiz = (long)maxwidth*cwidth >> 8;
162 >                        ysiz = nlines*cheight;
163 >                } else if (aspect > FTINY) {
164 >                        if (ysiz <= 0)
165 >                                ysiz = cheight*nlines;
166 >                        pictaspect = 256*nlines*aspect/maxwidth;
167 >                        if (pictaspect*xsiz < ysiz)
168 >                                ysiz = pictaspect*xsiz + 0.5;
169 >                        else
170 >                                xsiz = ysiz/pictaspect + 0.5;
171 >                        cheight = ysiz/nlines;
172 >                        cwidth = cheight/aspect;
173 >                } else {
174 >                        if (ysiz <= 0)
175 >                                ysiz = cheight*nlines;
176 >                        pictaspect = (double)ysiz/xsiz;
177 >                        aspect = pictaspect*maxwidth/(256*nlines);
178 >                        cheight = ysiz/nlines;
179 >                        cwidth = cheight/aspect;
180 >                }
181          } else {                        /* reverse orientation */
182 <                xsiz = nlines*cheight;
183 <                ysiz = (long)maxwidth*cwidth >> 8;
182 >                if (ysiz <= 0) {
183 >                        cwidth = cheight/aspect + 0.5;
184 >                        xsiz = nlines*cheight;
185 >                        ysiz = (long)maxwidth*cwidth >> 8;
186 >                } else if (aspect > FTINY) {
187 >                        if (xsiz <= 0)
188 >                                xsiz = cheight*nlines;
189 >                        pictaspect = maxwidth/(256*nlines*aspect);
190 >                        if (pictaspect*xsiz < ysiz)
191 >                                ysiz = pictaspect*xsiz + 0.5;
192 >                        else
193 >                                xsiz = ysiz/pictaspect + 0.5;
194 >                        cheight = xsiz/nlines;
195 >                        cwidth = cheight/aspect;
196 >                } else {
197 >                        if (xsiz <= 0)
198 >                                xsiz = cheight*nlines;
199 >                        pictaspect = (double)ysiz/xsiz;
200 >                        aspect = maxwidth/(256*nlines*pictaspect);
201 >                        cheight = xsiz/nlines;
202 >                        cwidth = cheight/aspect;
203 >                }
204          }
205          if (xsiz % SSS)
206                  xsiz += SSS - xsiz%SSS;
207          if (ysiz % SSS)
208                  ysiz += SSS - ysiz%SSS;
209          xdim = (xsiz+7)/8;
210 <        ourbitmap = (BYTE *)calloc(ysiz, xdim);
210 >        ourbitmap = (BYTE *)bmalloc(ysiz*xdim);
211          if (ourbitmap == NULL)
212                  error(SYSTEM, "Out of memory in makemap");
213 +        bzero((char *)ourbitmap, ysiz*xdim);
214   }
215  
216  
217   gettext(fp)                     /* get text from a file */
218   FILE  *fp;
219   {
173        char  *fgets();
220          char  buf[MAXLINE];
221          register LINE  *curl;
222          int  len;
# Line 191 | Line 237 | FILE  *fp;
237                          maxline = len;
238                  strncpy(curl->s, buf, len);
239                  curl->s[len] = '\0';
240 < len = uniftext(curl->sp, curl->s, ourfont);
240 >                if (spacing < -1./256.)
241 >                        len = squeeztext(curl->sp, curl->s, ourfont,
242 >                                        (int)(spacing*-256.));
243 >                else if (spacing > 1./256.)
244 >                        len = proptext(curl->sp, curl->s, ourfont,
245 >                                        (int)(spacing*256.), 3);
246 >                else
247 >                        len = uniftext(curl->sp, curl->s, ourfont);
248                  if (len > maxwidth)
249                          maxwidth = len;
250                  curl->next = ourtext;
# Line 227 | Line 280 | char  *av[];
280          ourtext->sp = (short *)malloc(sizeof(short)*(maxline+1));
281          if (ourtext->sp == NULL)
282                  goto memerr;
283 < maxwidth = squeeztext(ourtext->sp, ourtext->s, ourfont, 50);
283 >        if (spacing < -1./256.)
284 >                maxwidth = squeeztext(ourtext->sp, ourtext->s, ourfont,
285 >                                (int)(spacing*-256.));
286 >        else if (spacing > 1./256.)
287 >                maxwidth = proptext(ourtext->sp, ourtext->s, ourfont,
288 >                                (int)(spacing*256.), 3);
289 >        else
290 >                maxwidth = uniftext(ourtext->sp, ourtext->s, ourfont);
291          nlines = 1;
292          return;
293   memerr:
# Line 343 | Line 403 | FILE  *fp;
403   {
404          COLR  pixval[SSS*SSS+1];        /* possible pixel values */
405          COLOR  ctmp0, ctmp1;
406 <        double  d;
406 >        double  d;
407          COLR  *scanout;
408          int  x, y;
409          register int  i, j;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines