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

Comparing ray/src/px/oki20c.c (file contents):
Revision 2.7 by greg, Fri Jul 3 08:59:26 1992 UTC vs.
Revision 2.10 by greg, Mon Aug 2 14:39:07 1993 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 6 | Line 6 | static char SCCSid[] = "$SunId$ LBL";
6  
7   /*
8   *  oki20c.c - program to dump pixel file to OkiMate 20 color printer.
9 *
10 *     6/10/87
9   */
10  
11   #include  <stdio.h>
12 + #ifdef MSDOS
13 + #include  <fcntl.h>
14 + #endif
15  
16   #include  "color.h"
17   #include  "resolu.h"
18  
19 < #define  NROWS          1440            /* 10" at 144 dpi */
20 < #define  NCOLS          960             /* 8" at 120 dpi */
19 > #define  NROWS          1440            /* 10" at 144 dpi */
20 > #define  NCOLS          960             /* 8" at 120 dpi */
21  
22 < #define  ASPECT         (120./144.)     /* pixel aspect ratio */
22 > #define  ASPECT         (120./144.)     /* pixel aspect ratio */
23  
24 < #define  FILTER         "pfilt -1 -x %d -y %d -p %f %s",NCOLS,NROWS,ASPECT
24 > #define  FILTER         "pfilt -1 -x %d -y %d -p %f %s",NCOLS,NROWS,ASPECT
25  
26   /*
27 < *  Subtractive primaries are ordered:  Yellow, Magenta, Cyan.
27 > *  Subtractive primaries are ordered:  Yellow, Magenta, Cyan.
28   */
29  
30 < #define  sub_add(sub)   (2-(sub))       /* map subtractive to additive pri. */
30 > #define  sub_add(sub)   (2-(sub))       /* map subtractive to additive pri. */
31  
31 #ifdef  BSD
32 #define  clearlbuf()    bzero((char *)lpat, sizeof(lpat))
33 #else
34 #define  clearlbuf()    (void)memset((char *)lpat, 0, sizeof(lpat))
35 #endif
36
32   long  lpat[NCOLS][3];
33  
34   int  dofilter = 0;              /* filter through pfilt first? */
35  
36 + extern FILE  *popen();
37  
38 +
39   main(argc, argv)
40   int  argc;
41   char  *argv[];
42   {
43          int  i, status = 0;
44 <        
44 > #ifdef MSDOS
45 >        extern int  _fmode;
46 >        _fmode = O_BINARY;
47 >        setmode(fileno(stdin), O_BINARY);
48 >        setmode(fileno(stdout), O_BINARY);
49 > #endif
50          if (argc > 1 && !strcmp(argv[1], "-p")) {
51                  dofilter++;
52                  argv++; argc--;
53          }
52 #ifdef _IOLBF
53        stdout->_flag &= ~_IOLBF;
54 #endif
54          if (argc < 2)
55                  status = printp(NULL) == -1;
56          else
# Line 103 | Line 102 | char  *fname;
102          }
103                                  /* set line spacing (overlap for knitting) */
104          fputs("\0333\042", stdout);
106                                /* clear line buffer */
107        clearlbuf();
105                                  /* put out scanlines */
106          for (i = yres-1; i >= 0; i--) {
107                  if (freadcolrs(scanline, xres, input) < 0) {
# Line 140 | Line 137 | int  y;
137                  for (j = 0; j < 3; j++)
138                          for (i = 0; i < len; i++)
139                                  lpat[i][j] |= (long)colbit(scan[i],i,j) << bpos;
140 +                return;
141 +        }
142 +        fputs("\033\031", stdout);
143  
144 <        } else {
145 <
146 <                fputs("\033\031", stdout);
147 <
148 <                for (j = 0; j < 3; j++) {
149 <                        i = (NCOLS + len)/2;            /* center image */
150 <                        fputs("\033%O", stdout);
151 <                        putchar(i & 255);
152 <                        putchar(i >> 8);
153 <                        while (i-- > len) {
154 <                                putchar(0);
155 <                                putchar(0);
156 <                                putchar(0);
157 <                        }
158 <                        for (i = 0; i < len; i++) {
159 <                                c = lpat[i][j] | colbit(scan[i],i,j);
160 <                                                        /* repeat this row */
144 >        for (j = 0; j < 3; j++) {
145 >                i = (NCOLS + len)/2;            /* center image */
146 >                fputs("\033%O", stdout);
147 >                putchar(i & 255);
148 >                putchar(i >> 8);
149 >                while (i-- > len) {
150 >                        putchar(0);
151 >                        putchar(0);
152 >                        putchar(0);
153 >                }
154 >                for (i = 0; i < len; i++) {
155 >                        c = lpat[i][j] | colbit(scan[i],i,j);
156 >                        putchar((int)(c>>16));
157 >                        putchar((int)(c>>8 & 255));
158 >                        putchar((int)(c & 255));
159 >                        if (y)                  /* repeat this row */
160                                  lpat[i][j] = (c & 1) << 23;
161 <                                putchar(c>>16);
162 <                                putchar(c>>8 & 255);
164 <                                putchar(c & 255);
165 <                        }
166 <                        putchar('\r');
161 >                        else                    /* or clear for next image */
162 >                                lpat[i][j] = 0L;
163                  }
164 <                putchar('\n');
169 <                fflush(stdout);
164 >                putchar('\r');
165          }
166 +        putchar('\n');
167 +        fflush(stdout);
168   }
169  
170  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines