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

Comparing ray/src/rt/rpict.c (file contents):
Revision 1.21 by greg, Tue Jun 26 09:00:12 1990 UTC vs.
Revision 2.18 by greg, Tue Nov 10 21:24:34 1992 UTC

# Line 1 | Line 1
1 < /* Copyright (c) 1986 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 15 | Line 15 | static char SCCSid[] = "$SunId$ LBL";
15   #ifdef BSD
16   #include  <sys/time.h>
17   #include  <sys/resource.h>
18 #else
19 #include  <signal.h>
18   #endif
21 #include  <fcntl.h>
19  
20 + #include  <signal.h>
21 +
22   #include  "view.h"
23  
24 + #include  "resolu.h"
25 +
26   #include  "random.h"
27  
28 + #include  "paths.h"
29 +
30 + int  dimlist[MAXDIM];                   /* sampling dimensions */
31 + int  ndims = 0;                         /* number of sampling dimensions */
32 + int  samplendx;                         /* sample index number */
33 +
34   VIEW  ourview = STDVIEW;                /* view parameters */
35   int  hresolu = 512;                     /* horizontal resolution */
36   int  vresolu = 512;                     /* vertical resolution */
37 < double  pixaspect = 1.0;                /* pixel aspect ratio */
37 > double  pixaspect = 1.0;                /* pixel aspect ratio */
38  
39   int  psample = 4;                       /* pixel sample size */
40 < double  maxdiff = .05;                  /* max. difference for interpolation */
41 < double  dstrpix = 0.67;                 /* square pixel distribution */
40 > double  maxdiff = .05;                  /* max. difference for interpolation */
41 > double  dstrpix = 0.67;                 /* square pixel distribution */
42  
43 < double  dstrsrc = 0.0;                  /* square source distribution */
44 < double  shadthresh = .05;               /* shadow threshold */
45 < double  shadcert = .5;                  /* shadow certainty */
43 > double  dstrsrc = 0.0;                  /* square source distribution */
44 > double  shadthresh = .05;               /* shadow threshold */
45 > double  shadcert = .5;                  /* shadow certainty */
46 > int  directrelay = 1;                   /* number of source relays */
47 > int  vspretest = 512;                   /* virtual source pretest density */
48 > int  directinvis = 0;                   /* sources invisible? */
49 > double  srcsizerat = .25;               /* maximum ratio source size/dist. */
50  
51 + double  specthresh = .15;               /* specular sampling threshold */
52 + double  specjitter = 1.;                /* specular sampling jitter */
53 +
54   int  maxdepth = 6;                      /* maximum recursion depth */
55 < double  minweight = 5e-3;               /* minimum ray weight */
55 > double  minweight = 5e-3;               /* minimum ray weight */
56  
57   COLOR  ambval = BLKCOLOR;               /* ambient value */
58 < double  ambacc = 0.2;                   /* ambient accuracy */
58 > double  ambacc = 0.2;                   /* ambient accuracy */
59   int  ambres = 32;                       /* ambient resolution */
60   int  ambdiv = 128;                      /* ambient divisions */
61   int  ambssamp = 0;                      /* ambient super-samples */
# Line 49 | Line 63 | int  ambounce = 0;                     /* ambient bounces */
63   char  *amblist[128];                    /* ambient include/exclude list */
64   int  ambincl = -1;                      /* include == 1, exclude == 0 */
65  
66 + #ifdef MSDOS
67 + int  ralrm = 60;                        /* seconds between reports */
68 + #else
69   int  ralrm = 0;                         /* seconds between reports */
70 + #endif
71  
72 < double  pctdone = 0.0;                  /* percentage done */
72 > double  pctdone = 0.0;                  /* percentage done */
73  
74 + long  tlastrept = 0L;                   /* time at last report */
75 +
76 + extern long  time();
77 + extern long  tstart;                    /* starting time */
78 +
79   extern long  nrays;                     /* number of rays traced */
80  
81 < #define  MAXDIV         32              /* maximum sample size */
81 > #define  MAXDIV         16              /* maximum sample size */
82  
83 < #define  pixjitter()    (.5+dstrpix*(.5-frandom()))
83 > #define  pixjitter()    (.5+dstrpix*(.5-frandom()))
84  
85 < double  pixvalue();
85 > #define  RFTEMPLATE     "rfXXXXXX"
86 > #define  HFTEMPLATE     TEMPLATE
87  
88 + static char  *hfname = NULL;            /* header file name */
89 + static FILE  *hfp = NULL;               /* header file pointer */
90  
91 + static int  hres, vres;                 /* resolution for this frame */
92 +
93 + extern char  *mktemp();
94 +
95 + double  pixvalue();
96 +
97 +
98   quit(code)                      /* quit program */
99   int  code;
100   {
101 <        if (code || ralrm > 0)          /* report status */
101 >        if (code)                       /* report status */
102                  report();
103 <
103 >        if (hfname != NULL) {           /* delete header file */
104 >                if (hfp != NULL)
105 >                        fclose(hfp);
106 >                unlink(hfname);
107 >        }
108          exit(code);
109   }
110  
111  
112 + #ifdef BSD
113   report()                /* report progress */
114   {
77 #ifdef BSD
115          struct rusage  rubuf;
116 <        double  t;
116 >        double  t;
117  
118          getrusage(RUSAGE_SELF, &rubuf);
119          t = (rubuf.ru_utime.tv_usec + rubuf.ru_stime.tv_usec) / 1e6;
# Line 87 | Line 124 | report()               /* report progress */
124  
125          sprintf(errmsg, "%ld rays, %4.2f%% done after %5.4f CPU hours\n",
126                          nrays, pctdone, t/3600.0);
127 +        eputs(errmsg);
128 +        tlastrept = time((long *)0);
129 + }
130   #else
131 + report()                /* report progress */
132 + {
133 +        tlastrept = time((long *)0);
134 +        sprintf(errmsg, "%ld rays, %4.2f%% done after %5.4f hours\n",
135 +                        nrays, pctdone, (tlastrept-tstart)/3600.0);
136 +        eputs(errmsg);
137          signal(SIGALRM, report);
138 <        sprintf(errmsg, "%ld rays, %4.2f%% done\n", nrays, pctdone);
138 > }
139   #endif
94        eputs(errmsg);
140  
141 <        if (ralrm > 0)
142 <                alarm(ralrm);
141 >
142 > openheader()                    /* save standard output to header file */
143 > {
144 >        hfname = mktemp(HFTEMPLATE);
145 >        if (freopen(hfname, "w", stdout) == NULL) {
146 >                sprintf(errmsg, "cannot open header file \"%s\"", hfname);
147 >                error(SYSTEM, errmsg);
148 >        }
149   }
150  
151  
152 + dupheader()                     /* repeat header on standard output */
153 + {
154 +        register int  c;
155 +
156 +        if (hfp == NULL) {
157 +                if ((hfp = fopen(hfname, "r")) == NULL)
158 +                        error(SYSTEM, "error reopening header file");
159 + #ifdef MSDOS
160 +                setmode(fileno(hfp), O_BINARY);
161 + #endif
162 +        } else if (fseek(hfp, 0L, 0) < 0)
163 +                error(SYSTEM, "seek error on header file");
164 +        while ((c = getc(hfp)) != EOF)
165 +                putchar(c);
166 + }
167 +
168 +
169 + rpict(seq, pout, zout, prvr)                    /* generate image(s) */
170 + int  seq;
171 + char  *pout, *zout, *prvr;
172 + /*
173 + * If seq is greater than zero, then we will render a sequence of
174 + * images based on view parameter strings read from the standard input.
175 + * If pout is NULL, then all images will be sent to the standard ouput.
176 + * If seq is greater than zero and prvr is an integer, then it is the
177 + * frame number at which rendering should begin.  Preceeding view parameter
178 + * strings will be skipped in the input.
179 + * If pout and prvr are the same, prvr is renamed to avoid overwriting.
180 + * Note that pout and zout should contain %d format specifications for
181 + * sequenced file naming.
182 + */
183 + {
184 +        extern char  *rindex(), *strncpy(), *strcat();
185 +        char  fbuf[128], fbuf2[128];
186 +        register char  *cp;
187 +        RESOLU  rs;
188 +        double  pa;
189 +                                        /* check sampling */
190 +        if (psample < 1)
191 +                psample = 1;
192 +        else if (psample > MAXDIV) {
193 +                sprintf(errmsg, "pixel sampling reduced from %d to %d",
194 +                                psample, MAXDIV);
195 +                error(WARNING, errmsg);
196 +                psample = MAXDIV;
197 +        }
198 +                                        /* get starting frame */
199 +        if (seq <= 0)
200 +                seq = 0;
201 +        else if (prvr != NULL && isint(prvr)) {
202 +                register int  rn;               /* skip to specified view */
203 +                if ((rn = atoi(prvr)) < seq)
204 +                        error(USER, "recover frame less than start frame");
205 +                if (pout == NULL)
206 +                        error(USER, "missing output file specification");
207 +                for ( ; seq < rn; seq++)
208 +                        if (nextview(stdin) == EOF)
209 +                                error(USER, "unexpected EOF on view input");
210 +                prvr = fbuf;                    /* mark for renaming */
211 +        }
212 +        if (pout != NULL & prvr != NULL) {
213 +                sprintf(fbuf, pout, seq);
214 +                if (!strcmp(prvr, fbuf)) {      /* rename */
215 +                        strcpy(fbuf2, fbuf);
216 +                        for (cp = fbuf2; *cp; cp++)
217 +                                ;
218 +                        while (cp > fbuf2 && !ISDIRSEP(cp[-1]))
219 +                                cp--;
220 +                        strcpy(cp, RFTEMPLATE);
221 +                        prvr = mktemp(fbuf2);
222 +                        if (rename(fbuf, prvr) < 0 && errno != ENOENT) {
223 +                                sprintf(errmsg,
224 +                                        "cannot rename \"%s\" to \"%s\"",
225 +                                                fbuf, prvr);
226 +                                error(SYSTEM, errmsg);
227 +                        }
228 +                }
229 +        }
230 +                                        /* render sequence */
231 +        do {
232 +                if (seq && nextview(stdin) == EOF)
233 +                        break;
234 +                if (pout != NULL) {
235 +                        sprintf(fbuf, pout, seq);
236 +                        if (freopen(fbuf, "w", stdout) == NULL) {
237 +                                sprintf(errmsg,
238 +                                        "cannot open output file \"%s\"", fbuf);
239 +                                error(SYSTEM, errmsg);
240 +                        }
241 + #ifdef MSDOS
242 +                        setmode(fileno(stdout), O_BINARY);
243 + #endif
244 +                        dupheader();
245 +                }
246 +                hres = hresolu; vres = vresolu; pa = pixaspect;
247 +                if (prvr != NULL)
248 +                        if (viewfile(prvr, &ourview, &rs) <= 0
249 +                                        || rs.or != PIXSTANDARD) {
250 +                                sprintf(errmsg,
251 +                        "cannot recover view parameters from \"%s\"", prvr);
252 +                                error(WARNING, errmsg);
253 +                        } else {
254 +                                pa = 0.0;
255 +                                hres = scanlen(&rs);
256 +                                vres = numscans(&rs);
257 +                        }
258 +                if ((cp = setview(&ourview)) != NULL)
259 +                        error(USER, cp);
260 +                normaspect(viewaspect(&ourview), &pa, &hres, &vres);
261 +                if (seq) {
262 +                        if (ralrm > 0) {
263 +                                fprintf(stderr, "FRAME %d:", seq);
264 +                                fprintview(&ourview, stderr);
265 +                                putc('\n', stderr);
266 +                                fflush(stderr);
267 +                        }
268 +                        printf("FRAME=%d\n", seq);
269 +                }
270 +                fputs(VIEWSTR, stdout);
271 +                fprintview(&ourview, stdout);
272 +                putchar('\n');
273 +                if (pa < .99 || pa > 1.01)
274 +                        fputaspect(pa, stdout);
275 +                fputformat(COLRFMT, stdout);
276 +                putchar('\n');
277 +                if (zout != NULL)
278 +                        sprintf(cp=fbuf, zout, seq);
279 +                else
280 +                        cp = NULL;
281 +                render(cp, prvr);
282 +                prvr = NULL;
283 +        } while (seq++);
284 + }
285 +
286 +
287 + nextview(fp)                            /* get next view from fp */
288 + FILE  *fp;
289 + {
290 +        char  linebuf[256];
291 +
292 +        while (fgets(linebuf, sizeof(linebuf), fp) != NULL)
293 +                if (isview(linebuf) && sscanview(&ourview, linebuf) > 0)
294 +                        return(0);
295 +        return(EOF);
296 + }      
297 +
298 +
299   render(zfile, oldfile)                          /* render the scene */
300   char  *zfile, *oldfile;
301   {
302          extern long  lseek();
303          COLOR  *scanbar[MAXDIV+1];      /* scanline arrays of pixel values */
304          float  *zbar[MAXDIV+1];         /* z values */
305 +        char  *sampdens;                /* previous sample density */
306          int  ypos;                      /* current scanline */
307          int  ystep;                     /* current y step size */
308 +        int  hstep;                     /* h step size */
309          int  zfd;
310          COLOR  *colptr;
311          float  *zptr;
312          register int  i;
113                                        /* check sampling */
114        if (psample < 1)
115                psample = 1;
116        else if (psample > MAXDIV)
117                psample = MAXDIV;
313                                          /* allocate scanlines */
314          for (i = 0; i <= psample; i++) {
315 <                scanbar[i] = (COLOR *)malloc(hresolu*sizeof(COLOR));
315 >                scanbar[i] = (COLOR *)malloc(hres*sizeof(COLOR));
316                  if (scanbar[i] == NULL)
317                          goto memerr;
318          }
319 +        hstep = (psample*140+49)/99;            /* quincunx sampling */
320 +        ystep = (psample*99+70)/140;
321 +        if (hstep > 2) {
322 +                i = hres/hstep + 2;
323 +                if ((sampdens = malloc(i)) == NULL)
324 +                        goto memerr;
325 +                while (i--)
326 +                        sampdens[i] = hstep;
327 +        } else
328 +                sampdens = NULL;
329                                          /* open z file */
330          if (zfile != NULL) {
331                  if ((zfd = open(zfile, O_WRONLY|O_CREAT, 0666)) == -1) {
332                          sprintf(errmsg, "cannot open z file \"%s\"", zfile);
333                          error(SYSTEM, errmsg);
334                  }
335 + #ifdef MSDOS
336 +                setmode(zfd, O_BINARY);
337 + #endif
338                  for (i = 0; i <= psample; i++) {
339 <                        zbar[i] = (float *)malloc(hresolu*sizeof(float));
339 >                        zbar[i] = (float *)malloc(hres*sizeof(float));
340                          if (zbar[i] == NULL)
341                                  goto memerr;
342                  }
# Line 138 | Line 346 | char  *zfile, *oldfile;
346                          zbar[i] = NULL;
347          }
348                                          /* write out boundaries */
349 <        fputresolu(YMAJOR|YDECR, hresolu, vresolu, stdout);
349 >        fprtresolu(hres, vres, stdout);
350                                          /* recover file and compute first */
351          i = salvage(oldfile);
352 <        if (zfd != -1 && lseek(zfd, (long)i*hresolu*sizeof(float), 0) == -1)
352 >        if (zfd != -1 && i > 0 &&
353 >                        lseek(zfd, (long)i*hres*sizeof(float), 0) == -1)
354                  error(SYSTEM, "z file seek error in render");
355 <        ypos = vresolu-1 - i;
356 <        fillscanline(scanbar[0], zbar[0], hresolu, ypos, psample);
357 <        ystep = psample;
355 >        pctdone = 100.0*i/vres;
356 >        if (ralrm > 0)                  /* report init stats */
357 >                report();
358 > #ifndef  BSD
359 >        else
360 > #endif
361 >        signal(SIGALRM, report);
362 >        ypos = vres-1 - i;
363 >        fillscanline(scanbar[0], zbar[0], sampdens, hres, ypos, hstep);
364                                                  /* compute scanlines */
365          for (ypos -= ystep; ypos > -ystep; ypos -= ystep) {
151                                                        /* record progress */
152                pctdone = 100.0*(vresolu-1-ypos-ystep)/vresolu;
366                                                          /* bottom adjust? */
367                  if (ypos < 0) {
368                          ystep += ypos;
# Line 162 | Line 375 | char  *zfile, *oldfile;
375                  zbar[ystep] = zbar[0];
376                  zbar[0] = zptr;
377                                                          /* fill base line */
378 <                fillscanline(scanbar[0], zbar[0], hresolu, ypos, psample);
378 >                fillscanline(scanbar[0], zbar[0], sampdens,
379 >                                hres, ypos, hstep);
380                                                          /* fill bar */
381 <                fillscanbar(scanbar, zbar, hresolu, ypos, ystep);
381 >                fillscanbar(scanbar, zbar, hres, ypos, ystep);
382                                                          /* write it out */
383 + #ifndef  BSD
384 +                signal(SIGALRM, SIG_IGN);       /* don't interrupt writes */
385 + #endif
386                  for (i = ystep; i > 0; i--) {
387                          if (zfd != -1 && write(zfd, (char *)zbar[i],
388 <                                        hresolu*sizeof(float))
389 <                                        < hresolu*sizeof(float))
388 >                                        hres*sizeof(float))
389 >                                        < hres*sizeof(float))
390                                  goto writerr;
391 <                        if (fwritescan(scanbar[i], hresolu, stdout) < 0)
391 >                        if (fwritescan(scanbar[i], hres, stdout) < 0)
392                                  goto writerr;
393                  }
394                  if (fflush(stdout) == EOF)
395                          goto writerr;
396 +                                                        /* record progress */
397 +                pctdone = 100.0*(vres-1-ypos)/vres;
398 +                if (ralrm > 0 && time((long *)0) >= tlastrept+ralrm)
399 +                        report();
400 + #ifndef  BSD
401 +                else
402 +                        signal(SIGALRM, report);
403 + #endif
404          }
405                                                  /* clean up */
406 +        signal(SIGALRM, SIG_IGN);
407          if (zfd != -1) {
408 <                if (write(zfd, (char *)zbar[0], hresolu*sizeof(float))
409 <                                < hresolu*sizeof(float))
408 >                if (write(zfd, (char *)zbar[0], hres*sizeof(float))
409 >                                < hres*sizeof(float))
410                          goto writerr;
411                  if (close(zfd) == -1)
412                          goto writerr;
413                  for (i = 0; i <= psample; i++)
414                          free((char *)zbar[i]);
415          }
416 <        fwritescan(scanbar[0], hresolu, stdout);
416 >        fwritescan(scanbar[0], hres, stdout);
417          if (fflush(stdout) == EOF)
418                  goto writerr;
419          for (i = 0; i <= psample; i++)
420                  free((char *)scanbar[i]);
421 +        if (sampdens != NULL)
422 +                free(sampdens);
423          pctdone = 100.0;
424 +        if (ralrm > 0)
425 +                report();
426          return;
427   writerr:
428          error(SYSTEM, "write error in render");
# Line 201 | Line 431 | memerr:
431   }
432  
433  
434 < fillscanline(scanline, zline, xres, y, xstep)   /* fill scan line at y */
435 < register COLOR  *scanline;
436 < register float  *zline;
434 > fillscanline(scanline, zline, sd, xres, y, xstep)       /* fill scan at y */
435 > register COLOR  *scanline;
436 > register float  *zline;
437 > register char  *sd;
438   int  xres, y, xstep;
439   {
440 <        int  b = xstep;
441 <        double  z;
440 >        static int  nc = 0;             /* number of calls */
441 >        int  bl = xstep, b = xstep;
442 >        double  z;
443          register int  i;
444          
445          z = pixvalue(scanline[0], 0, y);
446          if (zline) zline[0] = z;
447 <
448 <        for (i = xstep; i < xres-1+xstep; i += xstep) {
447 >                                /* zig-zag start for quincunx pattern */
448 >        for (i = ++nc & 1 ? xstep : xstep/2; i < xres-1+xstep; i += xstep) {
449                  if (i >= xres) {
450                          xstep += xres-1-i;
451                          i = xres-1;
452                  }
453                  z = pixvalue(scanline[i], i, y);
454                  if (zline) zline[i] = z;
455 <                
456 <                b = fillsample(scanline+i-xstep, zline ? zline+i-xstep : NULL,
457 <                                i-xstep, y, xstep, 0, b/2);
455 >                if (sd) b = sd[0] > sd[1] ? sd[0] : sd[1];
456 >                if (i <= xstep)
457 >                        b = fillsample(scanline, zline, 0, y, i, 0, b/2);
458 >                else
459 >                        b = fillsample(scanline+i-xstep,
460 >                                        zline ? zline+i-xstep : NULL,
461 >                                        i-xstep, y, xstep, 0, b/2);
462 >                if (sd) *sd++ = nc & 1 ? bl : b;
463 >                bl = b;
464          }
465 +        if (sd && nc & 1) *sd = bl;
466   }
467  
468  
469   fillscanbar(scanbar, zbar, xres, y, ysize)      /* fill interior */
470 < register COLOR  *scanbar[];
471 < register float  *zbar[];
470 > register COLOR  *scanbar[];
471 > register float  *zbar[];
472   int  xres, y, ysize;
473   {
474          COLOR  vline[MAXDIV+1];
# Line 259 | Line 498 | int  xres, y, ysize;
498  
499  
500   int
501 < fillsample(colline, zline, x, y, xlen, ylen, b) /* fill interior points */
502 < register COLOR  *colline;
503 < register float  *zline;
501 > fillsample(colline, zline, x, y, xlen, ylen, b) /* fill interior points */
502 > register COLOR  *colline;
503 > register float  *zline;
504   int  x, y;
505   int  xlen, ylen;
506   int  b;
507   {
508 <        extern double  fabs();
509 <        double  ratio;
271 <        double  z;
508 >        double  ratio;
509 >        double  z;
510          COLOR  ctmp;
511          int  ncut;
512          register int  len;
# Line 318 | Line 556 | pixvalue(col, x, y)            /* compute pixel value */
556   COLOR  col;                     /* returned color */
557   int  x, y;                      /* pixel position */
558   {
559 <        static RAY  thisray;    /* our ray for this pixel */
559 >        static RAY  thisray;
560  
561 <        viewray(thisray.rorg, thisray.rdir, &ourview,
562 <                        (x+pixjitter())/hresolu, (y+pixjitter())/vresolu);
561 >        if (viewray(thisray.rorg, thisray.rdir, &ourview,
562 >                        (x+pixjitter())/hres, (y+pixjitter())/vres) < 0) {
563 >                setcolor(col, 0.0, 0.0, 0.0);
564 >                return(0.0);
565 >        }
566  
567          rayorigin(&thisray, NULL, PRIMARY, 1.0);
568 <        
568 >
569 >        samplendx = pixnumber(x,y,hres,vres);   /* set pixel index */
570 >
571          rayvalue(&thisray);                     /* trace ray */
572  
573          copycolor(col, thisray.rcol);           /* return color */
# Line 349 | Line 592 | char  *oldfile;
592                  error(WARNING, errmsg);
593                  return(0);
594          }
595 + #ifdef MSDOS
596 +        setmode(fileno(fp), O_BINARY);
597 + #endif
598                                  /* discard header */
599          getheader(fp, NULL);
600                                  /* get picture size */
601 <        if (fgetresolu(&x, &y, fp) != (YMAJOR|YDECR)) {
601 >        if (!fscnresolu(&x, &y, fp)) {
602                  sprintf(errmsg, "bad recover file \"%s\"", oldfile);
603                  error(WARNING, errmsg);
604                  fclose(fp);
605                  return(0);
606          }
607  
608 <        if (x != hresolu || y != vresolu) {
608 >        if (x != hres || y != vres) {
609                  sprintf(errmsg, "resolution mismatch in recover file \"%s\"",
610                                  oldfile);
611                  error(USER, errmsg);
612          }
613  
614 <        scanline = (COLR *)malloc(hresolu*sizeof(COLR));
614 >        scanline = (COLR *)malloc(hres*sizeof(COLR));
615          if (scanline == NULL)
616                  error(SYSTEM, "out of memory in salvage");
617 <        for (y = 0; y < vresolu; y++) {
618 <                if (freadcolrs(scanline, hresolu, fp) < 0)
617 >        for (y = 0; y < vres; y++) {
618 >                if (freadcolrs(scanline, hres, fp) < 0)
619                          break;
620 <                if (fwritecolrs(scanline, hresolu, stdout) < 0)
620 >                if (fwritecolrs(scanline, hres, stdout) < 0)
621                          goto writerr;
622          }
623          if (fflush(stdout) == EOF)
# Line 381 | Line 627 | char  *oldfile;
627          unlink(oldfile);
628          return(y);
629   writerr:
630 <        error(SYSTEM, "write error in salvage");
630 >        sprintf(errmsg, "write error during recovery of \"%s\"", oldfile);
631 >        error(SYSTEM, errmsg);
632 > }
633 >
634 >
635 > int
636 > pixnumber(x, y, xres, yres)             /* compute pixel index (brushed) */
637 > register int  x, y;
638 > int  xres, yres;
639 > {
640 >        x -= y;
641 >        while (x < 0)
642 >                x += xres;
643 >        return((((x>>2)*yres + y) << 2) + (x & 3));
644   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines