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

Comparing ray/src/rt/rv2.c (file contents):
Revision 1.3 by greg, Fri Mar 3 18:34:33 1989 UTC vs.
Revision 1.22 by greg, Fri Apr 19 12:45:34 1991 UTC

# Line 28 | Line 28 | extern char  *progname;
28   getframe(s)                             /* get a new frame */
29   char  *s;
30   {
31 <        int  x0, y0, x1, y1;
32 <
33 <        if (!strcmp("all", s)) {
34 <                pframe.l = pframe.d = 0;
35 <                pframe.r = ourview.hresolu;
36 <                pframe.u = ourview.vresolu;
37 <                pdepth = 0;
31 >        if (getrect(s, &pframe) < 0)
32                  return;
39        }
40        if (sscanf(s, "%d %d %d %d", &x0, &y0, &x1, &y1) != 4) {
41                if (dev->getcur == NULL)
42                        return;
43                (*dev->comout)("Pick first corner\n");
44                if ((*dev->getcur)(&x0, &y0) == ABORT)
45                        return;
46                (*dev->comout)("Pick second corner\n");
47                if ((*dev->getcur)(&x1, &y1) == ABORT)
48                        return;
49        }
50        if (x0 < x1) {
51                pframe.l = x0;
52                pframe.r = x1;
53        } else {
54                pframe.l = x1;
55                pframe.r = x0;
56        }
57        if (y0 < y1) {
58                pframe.d = y0;
59                pframe.u = y1;
60        } else {
61                pframe.d = y1;
62                pframe.u = y0;
63        }
64        if (pframe.l < 0) pframe.l = 0;
65        if (pframe.d < 0) pframe.d = 0;
66        if (pframe.r > ourview.hresolu) pframe.r = ourview.hresolu;
67        if (pframe.u > ourview.vresolu) pframe.u = ourview.vresolu;
33          pdepth = 0;
34   }
35  
36  
37 + getrepaint(s)                           /* get area and repaint */
38 + char  *s;
39 + {
40 +        RECT  box;
41 +
42 +        if (getrect(s, &box) < 0)
43 +                return;
44 +        paintrect(&ptrunk, 0, 0, hresolu, vresolu, &box);
45 + }
46 +
47 +
48   getview(s)                              /* get/show view parameters */
49   char  *s;
50   {
51          FILE  *fp;
52          char  buf[128];
53 <        char  *fname, *getpath();
53 >        char  *fname;
54          int  change = 0;
55          VIEW  nv;
56  
57          if (sscanf(s, "%s", buf) == 1) {        /* write parameters to a file */
58 <                if ((fname = getpath(buf, NULL)) == NULL ||
58 >                if ((fname = getpath(buf, NULL, 0)) == NULL ||
59                                  (fp = fopen(fname, "a")) == NULL) {
60                          sprintf(errmsg, "cannot open \"%s\"", buf);
61                          error(COMMAND, errmsg);
# Line 87 | Line 63 | char  *s;
63                  }
64                  fputs(progname, fp);
65                  fprintview(&ourview, fp);
66 +                fputs(sskip(s), fp);
67                  fputs("\n", fp);
68                  fclose(fp);
69                  return;
70          }
71          sprintf(buf, "view type (%c): ", ourview.type);
72          (*dev->comout)(buf);
73 <        (*dev->comin)(buf);
73 >        (*dev->comin)(buf, NULL);
74          if (buf[0] == CTRL(C)) return;
75          if (buf[0] && buf[0] != ourview.type) {
76                  nv.type = buf[0];
# Line 103 | Line 80 | char  *s;
80          sprintf(buf, "view point (%.6g %.6g %.6g): ",
81                          ourview.vp[0], ourview.vp[1], ourview.vp[2]);
82          (*dev->comout)(buf);
83 <        (*dev->comin)(buf);
83 >        (*dev->comin)(buf, NULL);
84          if (buf[0] == CTRL(C)) return;
85          if (sscanf(buf, "%lf %lf %lf", &nv.vp[0], &nv.vp[1], &nv.vp[2]) == 3)
86                  change++;
# Line 112 | Line 89 | char  *s;
89          sprintf(buf, "view direction (%.6g %.6g %.6g): ",
90                          ourview.vdir[0], ourview.vdir[1], ourview.vdir[2]);
91          (*dev->comout)(buf);
92 <        (*dev->comin)(buf);
92 >        (*dev->comin)(buf, NULL);
93          if (buf[0] == CTRL(C)) return;
94          if (sscanf(buf,"%lf %lf %lf",&nv.vdir[0],&nv.vdir[1],&nv.vdir[2]) == 3)
95                  change++;
# Line 121 | Line 98 | char  *s;
98          sprintf(buf, "view up (%.6g %.6g %.6g): ",
99                          ourview.vup[0], ourview.vup[1], ourview.vup[2]);
100          (*dev->comout)(buf);
101 <        (*dev->comin)(buf);
101 >        (*dev->comin)(buf, NULL);
102          if (buf[0] == CTRL(C)) return;
103          if (sscanf(buf,"%lf %lf %lf",&nv.vup[0],&nv.vup[1],&nv.vup[2]) == 3)
104                  change++;
# Line 130 | Line 107 | char  *s;
107          sprintf(buf, "view horiz and vert size (%.6g %.6g): ",
108                          ourview.horiz, ourview.vert);
109          (*dev->comout)(buf);
110 <        (*dev->comin)(buf);
110 >        (*dev->comin)(buf, NULL);
111          if (buf[0] == CTRL(C)) return;
112          if (sscanf(buf, "%lf %lf", &nv.horiz, &nv.vert) == 2)
113                  change++;
114          else {
115                  nv.horiz = ourview.horiz; nv.vert = ourview.vert;
116          }
117 <        sprintf(buf, "x and y resolution (%d %d): ",
118 <                        ourview.hresolu, ourview.vresolu);
117 >        sprintf(buf, "view shift and lift (%.6g %.6g): ",
118 >                        ourview.hoff, ourview.voff);
119          (*dev->comout)(buf);
120 <        (*dev->comin)(buf);
120 >        (*dev->comin)(buf, NULL);
121          if (buf[0] == CTRL(C)) return;
122 <        if (sscanf(buf, "%d %d", &nv.hresolu, &nv.vresolu) == 2)
122 >        if (sscanf(buf, "%lf %lf", &nv.hoff, &nv.voff) == 2)
123                  change++;
124          else {
125 <                nv.hresolu = ourview.hresolu; nv.vresolu = ourview.vresolu;
125 >                nv.hoff = ourview.hoff; nv.voff = ourview.voff;
126          }
127          if (change)
128                  newview(&nv);
# Line 156 | Line 133 | lastview(s)                            /* return to a previous view */
133   char  *s;
134   {
135          char  buf[128];
136 <        char  *fname, *getpath();
136 >        char  *fname;
137          int  success;
138          VIEW  nv;
139  
140          if (sscanf(s, "%s", buf) == 1) {        /* get parameters from a file */
141 <                bcopy(&stdview, &nv, sizeof(VIEW));
142 <                if ((fname = getpath(buf, NULL)) == NULL ||
143 <                                (success = viewfile(fname, &nv)) == -1) {
141 >                copystruct(&nv, &stdview);
142 >                if ((fname = getpath(buf, NULL, 0)) == NULL ||
143 >                                (success = viewfile(fname, &nv, 0, 0)) == -1) {
144                          sprintf(errmsg, "cannot open \"%s\"", buf);
145                          error(COMMAND, errmsg);
146                          return;
# Line 174 | Line 151 | char  *s;
151                          newview(&nv);
152                  return;
153          }
154 <        if (oldview.hresolu == 0) {     /* no old view! */
154 >        if (oldview.type == 0) {        /* no old view! */
155                  error(COMMAND, "no previous view");
156                  return;
157          }
158 <        bcopy(&ourview, &nv, sizeof(VIEW));
159 <        bcopy(&oldview, &ourview, sizeof(VIEW));
160 <        bcopy(&nv, &oldview, sizeof(VIEW));
158 >        copystruct(&nv, &ourview);
159 >        copystruct(&ourview, &oldview);
160 >        copystruct(&oldview, &nv);
161          newimage();
162   }
163  
164  
188 getinterest(s, direc, vec, mp)          /* get area of interest */
189 char  *s;
190 int  direc;
191 FVECT  vec;
192 double  *mp;
193 {
194        int  x, y;
195        RAY  thisray;
196        register int  i;
197
198        if (sscanf(s, "%lf", mp) != 1)
199                *mp = 1.0;
200        else if (*mp < -FTINY)          /* negative zoom is reduction */
201                *mp = -1.0 / *mp;
202        else if (*mp <= FTINY) {        /* too small */
203                error(COMMAND, "illegal magnification");
204                return(-1);
205        }
206        if (sscanf(s, "%*lf %lf %lf %lf", &vec[0], &vec[1], &vec[2]) != 3) {
207                if (dev->getcur == NULL)
208                        return(-1);
209                (*dev->comout)("Pick view center\n");
210                if ((*dev->getcur)(&x, &y) == ABORT)
211                        return(-1);
212                rayview(thisray.rorg, thisray.rdir, &ourview, x+.5, y+.5);
213                if (!direc || ourview.type == VT_PAR) {
214                        rayorigin(&thisray, NULL, PRIMARY, 1.0);
215                        if (!localhit(&thisray, &thescene)) {
216                                error(COMMAND, "not a local object");
217                                return(-1);
218                        }
219                }
220                if (direc)
221                        if (ourview.type == VT_PAR)
222                                for (i = 0; i < 3; i++)
223                                        vec[i] = thisray.rop[i] - ourview.vp[i];
224                        else
225                                VCOPY(vec, thisray.rdir);
226                else
227                        VCOPY(vec, thisray.rop);
228        } else if (direc)
229                        for (i = 0; i < 3; i++)
230                                vec[i] -= ourview.vp[i];
231        return(0);
232 }
233
234
165   getaim(s)                               /* aim camera */
166   char  *s;
167   {
# Line 241 | Line 171 | char  *s;
171  
172          if (getinterest(s, 1, nv.vdir, &zfact) < 0)
173                  return;
174 +        nv.type = ourview.type;
175          VCOPY(nv.vp, ourview.vp);
176          VCOPY(nv.vup, ourview.vup);
177 <        nv.hresolu = ourview.hresolu; nv.vresolu = ourview.vresolu;
178 <        if ((nv.type = ourview.type) == VT_PAR) {
179 <                nv.horiz = ourview.horiz / zfact;
249 <                nv.vert = ourview.vert / zfact;
250 <        } else {
251 <                nv.horiz = atan(tan(ourview.horiz*(PI/180./2.))/zfact) /
252 <                                (PI/180./2.);
253 <                nv.vert = atan(tan(ourview.vert*(PI/180./2.))/zfact) /
254 <                                (PI/180./2.);
255 <        }
177 >        nv.hoff = ourview.hoff; nv.voff = ourview.voff;
178 >        nv.horiz = ourview.horiz; nv.vert = ourview.vert;
179 >        zoomview(&nv, zfact);
180          newview(&nv);
181   }
182  
# Line 265 | Line 189 | char  *s;
189  
190          if (getinterest(s, 0, vc, &mag) < 0)
191                  return;
192 <        moveview(0.0, mag, vc);
192 >        moveview(0.0, 0.0, mag, vc);
193   }
194  
195  
196   getrotate(s)                            /* rotate camera */
197   char  *s;
198   {
199 <        extern double  normalize();
199 >        extern double  normalize(), tan(), atan();
200          VIEW  nv;
201          FVECT  v1;
202 <        double  angle, elev;
202 >        double  angle, elev, zfact;
203          
204 <        elev = 0.0;
205 <        if (sscanf(s, "%lf %lf", &angle, &elev) < 1) {
204 >        elev = 0.0; zfact = 1.0;
205 >        if (sscanf(s, "%lf %lf %lf", &angle, &elev, &zfact) < 1) {
206                  error(COMMAND, "missing angle");
207                  return;
208          }
209          nv.type = ourview.type;
210          VCOPY(nv.vp, ourview.vp);
211          VCOPY(nv.vup, ourview.vup);
212 <        nv.horiz = ourview.horiz; nv.vert = ourview.vert;
289 <        nv.hresolu = ourview.hresolu; nv.vresolu = ourview.vresolu;
212 >        nv.hoff = ourview.hoff; nv.voff = ourview.voff;
213          spinvector(nv.vdir, ourview.vdir, ourview.vup, angle*(PI/180.));
214          if (elev != 0.0) {
215                  fcross(v1, nv.vdir, ourview.vup);
216                  normalize(v1);
217                  spinvector(nv.vdir, nv.vdir, v1, elev*(PI/180.));
218          }
219 +        nv.horiz = ourview.horiz; nv.vert = ourview.vert;
220 +        zoomview(&nv, zfact);
221          newview(&nv);
222   }
223  
# Line 301 | Line 226 | getpivot(s)                            /* pivot viewpoint */
226   register char  *s;
227   {
228          FVECT  vc;
229 <        double  angle, mag;
229 >        double  angle, elev, mag;
230  
231 <        if (sscanf(s, "%lf", &angle) != 1) {
231 >        elev = 0.0;
232 >        if (sscanf(s, "%lf %lf", &angle, &elev) < 1) {
233                  error(COMMAND, "missing angle");
234                  return;
235          }
236 <        if (getinterest(sskip(s), 0, vc, &mag) < 0)
236 >        if (getinterest(sskip(sskip(s)), 0, vc, &mag) < 0)
237                  return;
238 <        moveview(angle, mag, vc);
238 >        moveview(angle, elev, mag, vc);
239   }
240  
241  
# Line 333 | Line 259 | char  *s;
259                  if ((*dev->getcur)(&x, &y) == ABORT)
260                          return;
261                  r.l = r.d = 0;
262 <                r.r = ourview.hresolu; r.u = ourview.vresolu;
262 >                r.r = hresolu; r.u = vresolu;
263                  p = findrect(x, y, &ptrunk, &r, -1);
264                  e = 1.0;
265          } else {
# Line 345 | Line 271 | char  *s;
271                          if (*cp == '\0') {      /* interactive */
272                                  sprintf(buf, "exposure (%lf): ", exposure);
273                                  (*dev->comout)(buf);
274 <                                (*dev->comin)(buf);
274 >                                (*dev->comin)(buf, NULL);
275                                  for (cp = buf; isspace(*cp); cp++)
276                                          ;
277                                  if (*cp == '\0')
# Line 361 | Line 287 | char  *s;
287                          e *= atof(cp);
288          }
289          if (p != NULL) {                /* relative setting */
290 <                if (intens(p->v) <= FTINY) {
290 >                if (bright(p->v) <= FTINY) {
291                          error(COMMAND, "cannot normalize to zero");
292                          return;
293                  }
294 <                e *= 0.5 / intens(p->v);
294 >                e *= 0.5 / bright(p->v);
295          }
296          if (e <= FTINY || fabs(1.0 - e) <= FTINY)
297                  return;
# Line 383 | Line 309 | register char  *s;
309          extern double  minweight;
310          extern int  maxdepth;
311          extern double  dstrsrc;
312 +        extern double  shadthresh;
313 +        extern double  shadcert;
314          extern COLOR  ambval;
315          extern double  ambacc;
316          extern double  minarad;
# Line 395 | Line 323 | register char  *s;
323          char  buf[128];
324          
325          if (s[0] == '\0') {
326 <                (*dev->comout)("aa ab ad ar as av ds lr lw sd sp: ");
327 <                (*dev->comin)(buf);
326 >                (*dev->comout)("aa ab ad ar as av dc dj dt lr lw sp st: ");
327 >                (*dev->comin)(buf, NULL);
328                  s = buf;
329          }
330          switch (s[0]) {
# Line 407 | Line 335 | register char  *s;
335                                  sprintf(buf, "limit weight (%.6g): ",
336                                                  minweight);
337                                  (*dev->comout)(buf);
338 <                                (*dev->comin)(buf);
338 >                                (*dev->comin)(buf, NULL);
339                                  if (sscanf(buf, "%lf", &d0) != 1)
340                                          break;
341                          }
# Line 418 | Line 346 | register char  *s;
346                                  sprintf(buf, "limit reflection (%d): ",
347                                                  maxdepth);
348                                  (*dev->comout)(buf);
349 <                                (*dev->comin)(buf);
349 >                                (*dev->comin)(buf, NULL);
350                                  if (sscanf(buf, "%d", &i0) != 1)
351                                          break;
352                          }
# Line 428 | Line 356 | register char  *s;
356                          goto badparam;
357                  }
358                  break;
359 <        case 'd':                       /* distribute source */
360 <                if (s[1] != 's')
359 >        case 'd':                       /* direct */
360 >                switch (s[1]) {
361 >                case 'j':                       /* jitter */
362 >                        if (sscanf(s+2, "%lf", &d0) != 1) {
363 >                                sprintf(buf, "direct jitter (%.6g): ",
364 >                                                dstrsrc);
365 >                                (*dev->comout)(buf);
366 >                                (*dev->comin)(buf, NULL);
367 >                                if (sscanf(buf, "%lf", &d0) != 1)
368 >                                        break;
369 >                        }
370 >                        dstrsrc = d0;
371 >                        break;
372 >                case 'c':                       /* certainty */
373 >                        if (sscanf(s+2, "%lf", &d0) != 1) {
374 >                                sprintf(buf, "direct certainty (%.6g): ",
375 >                                                shadcert);
376 >                                (*dev->comout)(buf);
377 >                                (*dev->comin)(buf, NULL);
378 >                                if (sscanf(buf, "%lf", &d0) != 1)
379 >                                        break;
380 >                        }
381 >                        shadcert = d0;
382 >                        break;
383 >                case 't':                       /* threshold */
384 >                        if (sscanf(s+2, "%lf", &d0) != 1) {
385 >                                sprintf(buf, "direct threshold (%.6g): ",
386 >                                                shadthresh);
387 >                                (*dev->comout)(buf);
388 >                                (*dev->comin)(buf, NULL);
389 >                                if (sscanf(buf, "%lf", &d0) != 1)
390 >                                        break;
391 >                        }
392 >                        shadthresh = d0;
393 >                        break;
394 >                default:
395                          goto badparam;
434                if (sscanf(s+2, "%lf", &d0) != 1) {
435                        sprintf(buf, "distribute source (%.6g): ", dstrsrc);
436                        (*dev->comout)(buf);
437                        (*dev->comin)(buf);
438                        if (sscanf(buf, "%lf", &d0) != 1)
439                                break;
396                  }
441                dstrsrc = d0;
397                  break;
398          case 'a':                       /* ambient */
399                  switch (s[1]) {
# Line 450 | Line 405 | register char  *s;
405                                                  colval(ambval,GRN),
406                                                  colval(ambval,BLU));
407                                  (*dev->comout)(buf);
408 <                                (*dev->comin)(buf);
408 >                                (*dev->comin)(buf, NULL);
409                                  if (sscanf(buf, "%lf %lf %lf",
410                                                  &d0, &d1, &d2) != 3)
411                                          break;
# Line 462 | Line 417 | register char  *s;
417                                  sprintf(buf, "ambient accuracy (%.6g): ",
418                                                  ambacc);
419                                  (*dev->comout)(buf);
420 <                                (*dev->comin)(buf);
420 >                                (*dev->comin)(buf, NULL);
421                                  if (sscanf(buf, "%lf", &d0) != 1)
422                                          break;
423                          }
# Line 473 | Line 428 | register char  *s;
428                                  sprintf(buf, "ambient divisions (%d): ",
429                                                  ambdiv);
430                                  (*dev->comout)(buf);
431 <                                (*dev->comin)(buf);
431 >                                (*dev->comin)(buf, NULL);
432                                  if (sscanf(buf, "%d", &i0) != 1)
433                                          break;
434                          }
# Line 484 | Line 439 | register char  *s;
439                                  sprintf(buf, "ambient super-samples (%d): ",
440                                                  ambssamp);
441                                  (*dev->comout)(buf);
442 <                                (*dev->comin)(buf);
442 >                                (*dev->comin)(buf, NULL);
443                                  if (sscanf(buf, "%d", &i0) != 1)
444                                          break;
445                          }
# Line 495 | Line 450 | register char  *s;
450                                  sprintf(buf, "ambient bounces (%d): ",
451                                                  ambounce);
452                                  (*dev->comout)(buf);
453 <                                (*dev->comin)(buf);
453 >                                (*dev->comin)(buf, NULL);
454                                  if (sscanf(buf, "%d", &i0) != 1)
455                                          break;
456                          }
# Line 506 | Line 461 | register char  *s;
461                                  sprintf(buf, "ambient resolution (%d): ",
462                                                  ambres);
463                                  (*dev->comout)(buf);
464 <                                (*dev->comin)(buf);
464 >                                (*dev->comin)(buf, NULL);
465                                  if (sscanf(buf, "%d", &i0) != 1)
466                                          break;
467                          }
# Line 523 | Line 478 | register char  *s;
478                          if (sscanf(s+2, "%d", &i0) != 1) {
479                                  sprintf(buf, "sample pixel (%d): ", psample);
480                                  (*dev->comout)(buf);
481 <                                (*dev->comin)(buf);
481 >                                (*dev->comin)(buf, NULL);
482                                  if (sscanf(buf, "%d", &i0) != 1)
483                                          break;
484                          }
485                          psample = i0;
486                          pdepth = 0;
487                          break;
488 <                case 'd':                       /* difference */
488 >                case 't':                       /* threshold */
489                          if (sscanf(s+2, "%lf", &d0) != 1) {
490 <                                sprintf(buf, "sample difference (%.6g): ",
490 >                                sprintf(buf, "sample threshold (%.6g): ",
491                                                  maxdiff);
492                                  (*dev->comout)(buf);
493 <                                (*dev->comin)(buf);
493 >                                (*dev->comin)(buf, NULL);
494                                  if (sscanf(buf, "%lf", &d0) != 1)
495                                          break;
496                          }
# Line 574 | Line 529 | char  *s;
529                  if ((*dev->getcur)(&x, &y) == ABORT)
530                          return;
531  
532 <                rayview(thisray.rorg, thisray.rdir, &ourview, x+.5, y+.5);
533 <                
532 >                if (viewray(thisray.rorg, thisray.rdir, &ourview,
533 >                                (x+.5)/hresolu, (y+.5)/vresolu) < 0) {
534 >                        error(COMMAND, "not on image");
535 >                        return;
536 >                }
537 >
538          } else if (normalize(thisray.rdir) == 0.0) {
539                  error(COMMAND, "zero ray direction");
540                  return;
# Line 593 | Line 552 | char  *s;
552                                  ofun[thisray.ro->otype].funame,
553                                  thisray.ro->oname);
554                  (*dev->comout)(buf);
555 <                (*dev->comin)(buf);
555 >                (*dev->comin)(buf, NULL);
556                  if (thisray.rot >= FHUGE)
557                          (*dev->comout)("at infinity");
558                  else {
# Line 601 | Line 560 | char  *s;
560                                          thisray.rop[1], thisray.rop[2]);
561                          (*dev->comout)(buf);
562                  }
563 <                (*dev->comin)(buf);
563 >                (*dev->comin)(buf, NULL);
564                  sprintf(buf, "with value (%.6g %.6g %.6g)",
565                                  colval(thisray.rcol,RED),
566                                  colval(thisray.rcol,GRN),
567                                  colval(thisray.rcol,BLU));
568                  (*dev->comout)(buf);
569          }
570 <        (*dev->comin)(buf);
570 >        (*dev->comin)(buf, NULL);
571   }
572  
573  
# Line 616 | Line 575 | writepict(s)                           /* write the picture to a file */
575   char  *s;
576   {
577          static char  buf[128];
578 <        char  *fname, *getpath();
578 >        char  *fname;
579          FILE  *fp;
580          COLR  *scanline;
581          int  y;
# Line 625 | Line 584 | char  *s;
584                  error(COMMAND, "no file");
585                  return;
586          }
587 <        if ((fname = getpath(buf, NULL)) == NULL ||
587 >        if ((fname = getpath(buf, NULL, 0)) == NULL ||
588                          (fp = fopen(fname, "w")) == NULL) {
589                  sprintf(errmsg, "cannot open \"%s\"", buf);
590                  error(COMMAND, errmsg);
# Line 637 | Line 596 | char  *s;
596                                                  /* write header */
597          fputs(progname, fp);
598          fprintview(&ourview, fp);
599 <        fputs("\n", fp);
599 >        putc('\n', fp);
600          if (exposure != 1.0)
601 <                fprintf(fp, "EXPOSURE=%e\n", exposure);
602 <        fprintf(fp, "\n-Y %d +X %d\n", ourview.vresolu, ourview.hresolu);
601 >                fputexpos(exposure, fp);
602 >        if (dev->pixaspect != 1.0)
603 >                fputaspect(dev->pixaspect, fp);
604 >        fputformat(COLRFMT, fp);
605 >        putc('\n', fp);
606 >        fputresolu(YMAJOR|YDECR, hresolu, vresolu, fp);
607  
608 <        scanline = (COLR *)malloc(ourview.hresolu*sizeof(COLR));
608 >        scanline = (COLR *)malloc(hresolu*sizeof(COLR));
609          if (scanline == NULL)
610                  error(SYSTEM, "out of memory in writepict");
611 <        for (y = ourview.vresolu-1; y >= 0; y--) {
612 <                getpictcolrs(y, scanline, &ptrunk,
613 <                                ourview.hresolu, ourview.vresolu);
651 <                if (fwritecolrs(scanline, ourview.hresolu, fp) < 0)
611 >        for (y = vresolu-1; y >= 0; y--) {
612 >                getpictcolrs(y, scanline, &ptrunk, hresolu, vresolu);
613 >                if (fwritecolrs(scanline, hresolu, fp) < 0)
614                          break;
615          }
616          if (fclose(fp) < 0)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines