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.9 by greg, Sat Feb 22 02:07:27 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 + #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  
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
24   long  lpat[NCOLS];
25  
26   int  dofilter = 0;              /* filter through pfilt first? */
27  
28 + extern FILE  *popen();
29  
30 +
31   main(argc, argv)
32   int  argc;
33   char  *argv[];
34   {
35          int  i, status = 0;
36 <        
36 > #ifdef MSDOS
37 >        extern int  _fmode;
38 >        _fmode = O_BINARY;
39 >        setmode(fileno(stdin), O_BINARY);
40 >        setmode(fileno(stdout), O_BINARY);
41 > #endif
42          if (argc > 1 && !strcmp(argv[1], "-p")) {
43                  dofilter++;
44                  argv++; argc--;
45          }
46 #ifdef _IOLBF
47        stdout->_flag &= ~_IOLBF;
48 #endif
46          if (argc < 2)
47                  status = printp(NULL) == -1;
48          else
# Line 91 | Line 88 | char  *fname;
88                  fprintf(stderr, "%s: bad picture size\n", fname);
89                  return(-1);
90          }
91 <        if (xres > NCOLS || yres > NROWS) {
91 >        if (xres > NCOLS) {
92                  fprintf(stderr, "%s: resolution mismatch\n", fname);
93                  return(-1);
94          }
95                                  /* set line spacing (overlap for knitting) */
96 <        fputs("\0333\042", stdout);
100 <                                /* clear line buffer */
101 <        clearlbuf();
96 >        fputs("\0333\042\022", stdout);
97                                  /* put out scanlines */
98          for (i = yres-1; i >= 0; i--) {
99                  if (freadcolrs(scanline, xres, input) < 0) {
# Line 125 | Line 120 | COLR  scan[];
120   int  len;
121   int  y;
122   {
123 <        int  bpos;
123 >        int  bpos, start, end;
124          register long  c;
125          register int  i;
126  
127 <        if (bpos = y % 23) {
127 >        bpos = y % 23;
128 >        for (i = 0; i < len; i++)
129 >                lpat[i] |= (long)bit(scan[i],i) << bpos;
130  
131 <                for (i = 0; i < len; i++)
132 <                        lpat[i] |= (long)bit(scan[i],i) << bpos;
133 <
134 <        } else {
135 <
136 <                fputs("\033%O", stdout);
137 <                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);
131 >        if (bpos)
132 >                return;
133 >                                /* find limits of non-zero print buffer */
134 >        for (i = 0; lpat[i] == 0; i++)
135 >                if (i == len-1) {
136 >                        putchar('\n');
137 >                        return;
138                  }
139 <                putchar('\r');
140 <                putchar('\n');
141 <                fflush(stdout);
139 >        start = i - i%12;
140 >        i = len;
141 >        while (lpat[--i] == 0)
142 >                ;
143 >        end = i;
144 >                                /* skip to start position */
145 >        for (i = start/12; i-- > 0; )
146 >                putchar(' ');
147 >                                /* print non-zero portion of buffer */
148 >        fputs("\033%O", stdout);
149 >        i = end+1-start;
150 >        putchar(i & 255);
151 >        putchar(i >> 8);
152 >        for (i = start; i <= end; i++) {
153 >                c = lpat[i];
154 >                putchar((int)(c>>16));
155 >                putchar((int)(c>>8 & 255));
156 >                putchar((int)(c & 255));
157 >                if (y)                  /* repeat this row next time */
158 >                        lpat[i] = (c & 1) << 23;
159 >                else                    /* or clear for next image */
160 >                        lpat[i] = 0L;
161          }
162 +        putchar('\r');
163 +        putchar('\n');
164 +        fflush(stdout);
165   }
166  
167  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines