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.15 by schorsch, Mon Nov 10 12:28:56 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 + #include  <time.h>
10  
11 + #include  "platform.h"
12 + #include  "rtprocess.h"
13   #include  "color.h"
14   #include  "resolu.h"
15  
16 < #define  NROWS          1440            /* 10" at 144 dpi */
17 < #define  NCOLS          960             /* 8" at 120 dpi */
16 > #define  NROWS          1440            /* 10" at 144 dpi */
17 > #define  NCOLS          960             /* 8" at 120 dpi */
18  
19 < #define  ASPECT         (120./144.)     /* pixel aspect ratio */
19 > #define  ASPECT         (120./144.)     /* pixel aspect ratio */
20  
21 < #define  FILTER         "pfilt -1 -x %d -y %d -p %f %s",NCOLS,NROWS,ASPECT
21 > #define  FILTER         "pfilt -1 -x %d -y %d -p %f",NCOLS,NROWS,ASPECT
22 > #define  FILTER_F       "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? */
# Line 44 | Line 37 | int  argc;
37   char  *argv[];
38   {
39          int  i, status = 0;
40 <        
40 >        SET_DEFAULT_BINARY();
41 >        SET_FILE_BINARY(stdin);
42 >        SET_FILE_BINARY(stdout);
43          if (argc > 1 && !strcmp(argv[1], "-p")) {
44                  dofilter++;
45                  argv++; argc--;
# Line 61 | Line 56 | char  *argv[];
56   printp(fname)                           /* print a picture */
57   char  *fname;
58   {
59 <        char  buf[64];
59 >        char  buf[PATH_MAX];
60          FILE  *input;
61          int  xres, yres;
62          COLR  scanline[NCOLS];
63          int  i;
64  
65          if (dofilter) {
66 <                if (fname == NULL)
67 <                        fname = "";
68 <                sprintf(buf, FILTER, fname);
66 >                if (fname == NULL) {
67 >                        sprintf(buf, FILTER);
68 >                        fname = "<stdin>";
69 >                } else
70 >                        sprintf(buf, FILTER_F, fname);
71                  if ((input = popen(buf, "r")) == NULL) {
72                          fprintf(stderr, "Cannot execute: %s\n", buf);
73                          return(-1);
74                  }
78                fname = buf;
75          } else if (fname == NULL) {
76                  input = stdin;
77                  fname = "<stdin>";
# Line 93 | Line 89 | char  *fname;
89                  fprintf(stderr, "%s: bad picture size\n", fname);
90                  return(-1);
91          }
92 <        if (xres > NCOLS || yres > NROWS) {
92 >        if (xres > NCOLS) {
93                  fprintf(stderr, "%s: resolution mismatch\n", fname);
94                  return(-1);
95          }
96                                  /* set line spacing (overlap for knitting) */
97          fputs("\0333\042", stdout);
102                                /* clear line buffer */
103        clearlbuf();
104 #ifdef _IOLBF
105        stdout->_flag &= ~_IOLBF;
106 #endif
98                                  /* put out scanlines */
99          for (i = yres-1; i >= 0; i--) {
100                  if (freadcolrs(scanline, xres, input) < 0) {
# Line 134 | Line 125 | int  y;
125          register long  c;
126          register int  i, j;
127  
128 <        if (bpos = y % 23) {
128 >        if ( (bpos = y % 23) ) {
129  
130                  for (j = 0; j < 3; j++)
131                          for (i = 0; i < len; i++)
132                                  lpat[i][j] |= (long)colbit(scan[i],i,j) << bpos;
133 +                return;
134 +        }
135 +        fputs("\033\031", stdout);
136  
137 <        } else {
138 <
139 <                fputs("\033\031", stdout);
140 <
141 <                for (j = 0; j < 3; j++) {
142 <                        i = (NCOLS + len)/2;            /* center image */
143 <                        fputs("\033%O", stdout);
144 <                        putchar(i & 255);
145 <                        putchar(i >> 8);
146 <                        while (i-- > len) {
147 <                                putchar(0);
148 <                                putchar(0);
149 <                                putchar(0);
150 <                        }
151 <                        for (i = 0; i < len; i++) {
152 <                                c = lpat[i][j] | colbit(scan[i],i,j);
159 <                                                        /* repeat this row */
137 >        for (j = 0; j < 3; j++) {
138 >                i = (NCOLS + len)/2;            /* center image */
139 >                fputs("\033%O", stdout);
140 >                putchar(i & 255);
141 >                putchar(i >> 8);
142 >                while (i-- > len) {
143 >                        putchar(0);
144 >                        putchar(0);
145 >                        putchar(0);
146 >                }
147 >                for (i = 0; i < len; i++) {
148 >                        c = lpat[i][j] | colbit(scan[i],i,j);
149 >                        putchar((int)(c>>16));
150 >                        putchar((int)(c>>8 & 255));
151 >                        putchar((int)(c & 255));
152 >                        if (y)                  /* repeat this row */
153                                  lpat[i][j] = (c & 1) << 23;
154 <                                putchar(c>>16);
155 <                                putchar(c>>8 & 255);
163 <                                putchar(c & 255);
164 <                        }
165 <                        putchar('\r');
154 >                        else                    /* or clear for next image */
155 >                                lpat[i][j] = 0L;
156                  }
157 <                putchar('\n');
168 <                fflush(stdout);
157 >                putchar('\r');
158          }
159 +        putchar('\n');
160 +        fflush(stdout);
161   }
162  
163  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines