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.4 by greg, Tue Jun 16 15:34:47 1992 UTC vs.
Revision 2.5 by greg, Tue Jun 16 16:27:37 1992 UTC

# Line 16 | Line 16 | static char SCCSid[] = "$SunId$ LBL";
16  
17   #include  "font.h"
18  
19 < #define  SSS                    2       /* super-sample size */
19 > #ifndef  SSS
20 > #define  SSS                    3       /* super-sample size */
21 > #endif
22  
23   #define  MAXLINE                512     /* longest allowable line */
24  
# Line 29 | Line 31 | static char SCCSid[] = "$SunId$ LBL";
31  
32   char  *fontfile = "helvet.fnt";         /* our font file */
33  
34 < COLR  bgcolr = WHTCOLR;                 /* background color */
35 < COLR  fgcolr = BLKCOLR;                 /* foreground color */
34 > COLOR  bgcolor = WHTCOLOR;              /* background color */
35 > COLOR  fgcolor = BLKCOLOR;              /* foreground color */
36  
37   int  direct = 'r';                      /* direction (right, up, left, down) */
38  
39 < int  cheight = 32;                      /* character height */
39 > int  cheight = 32*SSS;                  /* character height */
40   double  aspect = 1.67;                  /* height/width character aspect */
41   int  cwidth;                            /* computed character width */
42  
# Line 77 | Line 79 | char  *argv[];
79                  case 'c':                       /* color */
80                          switch (argv[an][2]) {
81                          case 'f':                       /* foreground */
82 <                                setcolr(fgcolr, atof(argv[an+1]),
82 >                                setcolor(fgcolor, atof(argv[an+1]),
83                                                  atof(argv[an+2]),
84                                                  atof(argv[an+3]));
85                                  an += 3;
86                                  break;
87                          case 'b':                       /* background */
88 <                                setcolr(bgcolr, atof(argv[an+1]),
88 >                                setcolor(bgcolor, atof(argv[an+1]),
89                                                  atof(argv[an+2]),
90                                                  atof(argv[an+3]));
91                                  an += 3;
# Line 108 | Line 110 | char  *argv[];
110                          }
111                          break;
112                  case 'h':                       /* height of characters */
113 <                        cheight = atoi(argv[++an]);
113 >                        cheight = atoi(argv[++an])*SSS;
114                          break;
115                  case 'a':                       /* aspect ratio */
116                          aspect = atof(argv[++an]);
# Line 148 | Line 150 | makemap()                      /* create the bit map */
150   {
151          cwidth = cheight/aspect + 0.5;
152          if (direct == 'r' || direct == 'l') {
153 <                xsiz = maxline*cwidth;
153 >                xsiz = (long)maxwidth*cwidth >> 8;
154                  ysiz = nlines*cheight;
155          } else {                        /* reverse orientation */
156                  xsiz = nlines*cheight;
157 <                ysiz = maxline*cwidth;
157 >                ysiz = (long)maxwidth*cwidth >> 8;
158          }
159 +        if (xsiz % SSS)
160 +                xsiz += SSS - xsiz%SSS;
161 +        if (ysiz % SSS)
162 +                ysiz += SSS - ysiz%SSS;
163          xdim = (xsiz+7)/8;
164          ourbitmap = (BYTE *)calloc(ysiz, xdim);
165 <        if (ourbitmap == NULL) {
166 <                fprintf(stderr, "out of memory in makemap\n");
161 <                exit(1);
162 <        }
165 >        if (ourbitmap == NULL)
166 >                error(SYSTEM, "Out of memory in makemap");
167   }
168  
169  
# Line 196 | Line 200 | len = uniftext(curl->sp, curl->s, ourfont);
200          }
201          return;
202   memerr:
203 <        fprintf(stderr, "out of memory in gettext\n");
200 <        exit(1);
203 >        error(SYSTEM, "Out of memory in gettext");
204   }
205  
206  
# Line 224 | Line 227 | char  *av[];
227          ourtext->sp = (short *)malloc(sizeof(short)*(maxline+1));
228          if (ourtext->sp == NULL)
229                  goto memerr;
230 < maxwidth = uniftext(ourtext->sp, ourtext->s, ourfont);
230 > maxwidth = squeeztext(ourtext->sp, ourtext->s, ourfont, 50);
231          nlines = 1;
232          return;
233   memerr:
234 <        fprintf(stderr, "out of memory in arg_text\n");
232 <        exit(1);
234 >        error(SYSTEM, "Out of memory in arg_text");
235   }
236  
237  
# Line 339 | Line 341 | int  run, rise;
341   writemap(fp)                    /* write out bitmap */
342   FILE  *fp;
343   {
344 +        COLR  pixval[SSS*SSS+1];        /* possible pixel values */
345 +        COLOR  ctmp0, ctmp1;
346 +        double  d;
347          COLR  *scanout;
348 <        int  y;
349 <        register int  x;
348 >        int  x, y;
349 >        register int  i, j;
350 >        int  cnt;
351          register int  inglyph;
352  
353 <        fprintf(fp, "-Y %d +X %d\n", ysiz, xsiz);
353 >        fprintf(fp, "-Y %d +X %d\n", ysiz/SSS, xsiz/SSS);
354  
355 <        scanout = (COLR *)malloc(xsiz*sizeof(COLR));
356 <        if (scanout == NULL) {
357 <                fprintf(stderr, "out of memory in writemap\n");
358 <                exit(1);
355 >        scanout = (COLR *)malloc(xsiz/SSS*sizeof(COLR));
356 >        if (scanout == NULL)
357 >                error(SYSTEM, "Out of memory in writemap");
358 >        for (i = 0; i <= SSS*SSS; i++) {        /* compute possible values */
359 >                copycolor(ctmp0, fgcolor);
360 >                d = (double)i/(SSS*SSS);
361 >                scalecolor(ctmp0, d);
362 >                copycolor(ctmp1, bgcolor);
363 >                d = 1.0 - d;
364 >                scalecolor(ctmp1, d);
365 >                addcolor(ctmp0, ctmp1);
366 >                setcolr(pixval[i], colval(ctmp0,RED),
367 >                                colval(ctmp0,GRN), colval(ctmp0,BLU));
368          }
369 <        for (y = ysiz-1; y >= 0; y--) {
369 >        for (y = ysiz/SSS-1; y >= 0; y--) {
370                  inglyph = 0;
371 <                for (x = 0; x < xsiz; x++) {
372 <                        if (tstbit(x, y))
373 <                                inglyph ^= 1;
374 <                        if (inglyph)
375 <                                copycolr(scanout[x], fgcolr);
376 <                        else
377 <                                copycolr(scanout[x], bgcolr);
371 >                for (x = 0; x < xsiz/SSS; x++) {
372 >                        cnt = 0;
373 >                        for (j = 0; j < SSS; j++)
374 >                                for (i = 0; i < SSS; i++) {
375 >                                        if (tstbit(x*SSS+i, y*SSS+j))
376 >                                                inglyph ^= 1<<j;
377 >                                        if (inglyph & 1<<j)
378 >                                                cnt++;
379 >                                }
380 >                        copycolr(scanout[x], pixval[cnt]);
381                  }
382 <                if (fwritecolrs(scanout, xsiz, fp) < 0) {
382 >                if (fwritecolrs(scanout, xsiz/SSS, fp) < 0) {
383                          fprintf(stderr, "write error in writemap\n");
384                          exit(1);
385                  }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines