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

Comparing ray/src/px/oki20.c (file contents):
Revision 2.2 by greg, Sat Apr 18 09:10:51 1992 UTC vs.
Revision 2.11 by schorsch, Mon Oct 27 10:24:51 2003 UTC

# Line 1 | Line 1
1 /* Copyright (c) 1992 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
5 > *  oki20.c - program to dump pixel file to OkiMate 20 printer.
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 %s",NCOLS,NROWS,ASPECT
22  
25 #ifdef  BSD
26 #define  clearlbuf()    bzero((char *)lpat, sizeof(lpat))
27 #else
28 #define  clearlbuf()    (void)memset((char *)lpat, 0, sizeof(lpat))
29 #endif
30
23   long  lpat[NCOLS];
24  
25   int  dofilter = 0;              /* filter through pfilt first? */
# Line 38 | Line 30 | int  argc;
30   char  *argv[];
31   {
32          int  i, status = 0;
33 <        
33 >        SET_DEFAULT_BINARY();
34 >        SET_FILE_BINARY(stdin);
35 >        SET_FILE_BINARY(stdout);
36          if (argc > 1 && !strcmp(argv[1], "-p")) {
37                  dofilter++;
38                  argv++; argc--;
39          }
46 #ifdef _IOLBF
47        stdout->_flag &= ~_IOLBF;
48 #endif
40          if (argc < 2)
41                  status = printp(NULL) == -1;
42          else
# Line 91 | Line 82 | char  *fname;
82                  fprintf(stderr, "%s: bad picture size\n", fname);
83                  return(-1);
84          }
85 <        if (xres > NCOLS || yres > NROWS) {
85 >        if (xres > NCOLS) {
86                  fprintf(stderr, "%s: resolution mismatch\n", fname);
87                  return(-1);
88          }
89                                  /* set line spacing (overlap for knitting) */
90 <        fputs("\0333\042", stdout);
100 <                                /* clear line buffer */
101 <        clearlbuf();
90 >        fputs("\0333\042\022", stdout);
91                                  /* put out scanlines */
92          for (i = yres-1; i >= 0; i--) {
93                  if (freadcolrs(scanline, xres, input) < 0) {
# Line 125 | Line 114 | COLR  scan[];
114   int  len;
115   int  y;
116   {
117 <        int  bpos;
117 >        int  bpos, start, end;
118          register long  c;
119          register int  i;
120  
121 <        if (bpos = y % 23) {
121 >        bpos = y % 23;
122 >        for (i = 0; i < len; i++)
123 >                lpat[i] |= (long)bit(scan[i],i) << bpos;
124  
125 <                for (i = 0; i < len; i++)
126 <                        lpat[i] |= (long)bit(scan[i],i) << bpos;
127 <
128 <        } else {
129 <
130 <                fputs("\033%O", stdout);
131 <                putchar(len & 255);
141 <                putchar(len >> 8);
142 <                for (i = 0; i < len; i++) {
143 <                        c = lpat[i] | bit(scan[i],i);
144 <                                                /* repeat this row */
145 <                        lpat[i] = (c & 1) << 23;
146 <                        putchar(c>>16);
147 <                        putchar(c>>8 & 255);
148 <                        putchar(c & 255);
125 >        if (bpos)
126 >                return;
127 >                                /* find limits of non-zero print buffer */
128 >        for (i = 0; lpat[i] == 0; i++)
129 >                if (i == len-1) {
130 >                        putchar('\n');
131 >                        return;
132                  }
133 <                putchar('\r');
134 <                putchar('\n');
135 <                fflush(stdout);
133 >        start = i - i%12;
134 >        i = len;
135 >        while (lpat[--i] == 0)
136 >                ;
137 >        end = i;
138 >                                /* skip to start position */
139 >        for (i = start/12; i-- > 0; )
140 >                putchar(' ');
141 >                                /* print non-zero portion of buffer */
142 >        fputs("\033%O", stdout);
143 >        i = end+1-start;
144 >        putchar(i & 255);
145 >        putchar(i >> 8);
146 >        for (i = start; i <= end; i++) {
147 >                c = lpat[i];
148 >                putchar((int)(c>>16));
149 >                putchar((int)(c>>8 & 255));
150 >                putchar((int)(c & 255));
151 >                if (y)                  /* repeat this row next time */
152 >                        lpat[i] = (c & 1) << 23;
153 >                else                    /* or clear for next image */
154 >                        lpat[i] = 0L;
155          }
156 +        putchar('\r');
157 +        putchar('\n');
158 +        fflush(stdout);
159   }
160  
161  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines