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.4 by greg, Wed Jan 29 16:51:40 1992 UTC vs.
Revision 2.11 by greg, Sat Feb 22 02:07:27 2003 UTC

# Line 1 | Line 1
1 /* Copyright (c) 1991 Regents of the University of California */
2
1   #ifndef lint
2 < static char SCCSid[] = "$SunId$ LBL";
2 > static const char       RCSid[] = "$Id$";
3   #endif
6
4   /*
5   *  oki20c.c - program to dump pixel file to OkiMate 20 color printer.
9 *
10 *     6/10/87
6   */
7  
8   #include  <stdio.h>
9 + #ifdef MSDOS
10 + #include  <fcntl.h>
11 + #endif
12 + #include  <time.h>
13  
14   #include  "color.h"
15   #include  "resolu.h"
16  
17 < #define  NROWS          1440            /* 10" at 144 dpi */
18 < #define  NCOLS          960             /* 8" at 120 dpi */
17 > #define  NROWS          1440            /* 10" at 144 dpi */
18 > #define  NCOLS          960             /* 8" at 120 dpi */
19  
20 < #define  ASPECT         (120./144.)     /* pixel aspect ratio */
20 > #define  ASPECT         (120./144.)     /* pixel aspect ratio */
21  
22 < #define  FILTER         "pfilt -1 -x %d -y %d -p %f %s",NCOLS,NROWS,ASPECT
22 > #define  FILTER         "pfilt -1 -x %d -y %d -p %f %s",NCOLS,NROWS,ASPECT
23  
24   /*
25 < *  Subtractive primaries are ordered:  Yellow, Magenta, Cyan.
25 > *  Subtractive primaries are ordered:  Yellow, Magenta, Cyan.
26   */
27  
28 < #define  sub_add(sub)   (2-(sub))       /* map subtractive to additive pri. */
28 > #define  sub_add(sub)   (2-(sub))       /* map subtractive to additive pri. */
29  
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
30   long  lpat[NCOLS][3];
31  
32   int  dofilter = 0;              /* filter through pfilt first? */
33  
34 + extern FILE  *popen();
35  
36 +
37   main(argc, argv)
38   int  argc;
39   char  *argv[];
40   {
41          int  i, status = 0;
42 <        
42 > #ifdef MSDOS
43 >        extern int  _fmode;
44 >        _fmode = O_BINARY;
45 >        setmode(fileno(stdin), O_BINARY);
46 >        setmode(fileno(stdout), O_BINARY);
47 > #endif
48          if (argc > 1 && !strcmp(argv[1], "-p")) {
49                  dofilter++;
50                  argv++; argc--;
# Line 68 | Line 68 | char  *fname;
68          int  i;
69  
70          if (dofilter) {
71 <                if (fname == NULL)
72 <                        fname = "";
73 <                sprintf(buf, FILTER, fname);
71 >                if (fname == NULL) {
72 >                        sprintf(buf, FILTER, "");
73 >                        fname = "<stdin>";
74 >                } else
75 >                        sprintf(buf, FILTER, fname);
76                  if ((input = popen(buf, "r")) == NULL) {
77                          fprintf(stderr, "Cannot execute: %s\n", buf);
78                          return(-1);
79                  }
78                fname = buf;
80          } else if (fname == NULL) {
81                  input = stdin;
82                  fname = "<stdin>";
# Line 93 | Line 94 | char  *fname;
94                  fprintf(stderr, "%s: bad picture size\n", fname);
95                  return(-1);
96          }
97 <        if (xres > NCOLS || yres > NROWS) {
97 >        if (xres > NCOLS) {
98                  fprintf(stderr, "%s: resolution mismatch\n", fname);
99                  return(-1);
100          }
101                                  /* set line spacing (overlap for knitting) */
102          fputs("\0333\042", stdout);
102                                /* clear line buffer */
103        clearlbuf();
104 #ifdef _IOLBF
105        stdout->_flag &= ~_IOLBF;
106 #endif
103                                  /* put out scanlines */
104          for (i = yres-1; i >= 0; i--) {
105                  if (freadcolrs(scanline, xres, input) < 0) {
# Line 139 | Line 135 | int  y;
135                  for (j = 0; j < 3; j++)
136                          for (i = 0; i < len; i++)
137                                  lpat[i][j] |= (long)colbit(scan[i],i,j) << bpos;
138 +                return;
139 +        }
140 +        fputs("\033\031", stdout);
141  
142 <        } else {
143 <
144 <                fputs("\033\031", stdout);
145 <
146 <                for (j = 0; j < 3; j++) {
147 <                        i = (NCOLS + len)/2;            /* center image */
148 <                        fputs("\033%O", stdout);
149 <                        putchar(i & 255);
150 <                        putchar(i >> 8);
151 <                        while (i-- > len) {
152 <                                putchar(0);
153 <                                putchar(0);
154 <                                putchar(0);
155 <                        }
156 <                        for (i = 0; i < len; i++) {
157 <                                c = lpat[i][j] | colbit(scan[i],i,j);
159 <                                                        /* repeat this row */
142 >        for (j = 0; j < 3; j++) {
143 >                i = (NCOLS + len)/2;            /* center image */
144 >                fputs("\033%O", stdout);
145 >                putchar(i & 255);
146 >                putchar(i >> 8);
147 >                while (i-- > len) {
148 >                        putchar(0);
149 >                        putchar(0);
150 >                        putchar(0);
151 >                }
152 >                for (i = 0; i < len; i++) {
153 >                        c = lpat[i][j] | colbit(scan[i],i,j);
154 >                        putchar((int)(c>>16));
155 >                        putchar((int)(c>>8 & 255));
156 >                        putchar((int)(c & 255));
157 >                        if (y)                  /* repeat this row */
158                                  lpat[i][j] = (c & 1) << 23;
159 <                                putchar(c>>16);
160 <                                putchar(c>>8 & 255);
163 <                                putchar(c & 255);
164 <                        }
165 <                        putchar('\r');
159 >                        else                    /* or clear for next image */
160 >                                lpat[i][j] = 0L;
161                  }
162 <                putchar('\n');
168 <                fflush(stdout);
162 >                putchar('\r');
163          }
164 +        putchar('\n');
165 +        fflush(stdout);
166   }
167  
168  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines