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

Comparing ray/src/px/ra_pr.c (file contents):
Revision 1.2 by greg, Fri Sep 1 12:07:48 1989 UTC vs.
Revision 1.7 by greg, Fri Feb 9 13:59:19 1990 UTC

# Line 102 | Line 102 | char  *argv[];
102                          quiterr(errmsg);
103                  }
104                                          /* get header */
105 <                if (fread(&head, sizeof(head), 1, stdin) != 1)
105 >                if (fread((char *)&head, sizeof(head), 1, stdin) != 1)
106                          quiterr("missing header");
107                  if (head.ras_magic != RAS_MAGIC)
108                          quiterr("bad raster format");
# Line 113 | Line 113 | char  *argv[];
113                                  head.ras_depth != 8)
114                          quiterr("incompatible format");
115                                          /* put header */
116 <                printargs(argc, argv, stdout);
116 >                printargs(i, argv, stdout);
117                  putchar('\n');
118 <                printf("-Y %d +X %d\n", ymax, xmax);
118 >                fputresolu(YMAJOR|YDECR, xmax, ymax, stdout);
119                                          /* convert file */
120                  pr2ra(&head);
121          } else {
# Line 187 | Line 187 | register struct rasterfile  *h;
187                  return(NULL);
188                                          /* discard header */
189          getheader(p->fp, NULL);
190 <        if (fscanf(p->fp, "-Y %d +X %d\n", &ymax, &xmax) != 2)
190 >        if (fgetresolu(&xmax, &ymax, p->fp) != (YMAJOR|YDECR))
191                  quiterr("bad picture size");
192          p->nexty = 0;
193          p->bytes_line = 0;              /* variable length lines */
# Line 223 | Line 223 | register struct rasterfile  *h;
223          else if ((p->fp = fopen(fname, "w")) == NULL)
224                  return(NULL);
225                                          /* write header */
226 <        fwrite(h, sizeof(*h), 1, p->fp);
226 >        fwrite((char *)h, sizeof(*h), 1, p->fp);
227          p->nexty = -1;                  /* needs color map */
228          p->bytes_line = h->ras_width;
229          p->pos.b = 0;
# Line 243 | Line 243 | struct rasterfile  *h;
243          scanline = (COLR *)emalloc(xmax*sizeof(COLR));
244                                          /* get color table */
245          for (i = 0; i < 3; i ++)
246 <                if (fread(cmap[i], h->ras_maplength/3, 1, stdin) != 1)
246 >                if (fread((char *)cmap[i], h->ras_maplength/3, 1, stdin) != 1)
247                          quiterr("error reading color table");
248                                          /* convert table */
249          for (i = 0; i < h->ras_maplength/3; i++)
# Line 271 | Line 271 | picreadline3(y, l3)                    /* read in 3-byte scanline */
271   int  y;
272   register rgbpixel  *l3;
273   {
274 <        register BYTE   *l4;
275 <        register int    shift, c;
276 <        int     i;
274 >        register int    i;
275  
276 <        if (inpic->nexty != y) {                                /* find scanline */
276 >        if (inpic->nexty != y) {                        /* find scanline */
277                  if (inpic->bytes_line == 0) {
278                          if (inpic->pos.y[y] == 0) {
279                                  while (inpic->nexty < y) {
# Line 293 | Line 291 | register rgbpixel  *l3;
291                  quiterr("read error in picreadline3");
292          inpic->nexty = y+1;
293                                                          /* convert scanline */
294 <        for (l4=inline[0], i=xmax; i--; l4+=4, l3++) {
295 <                shift = l4[EXP] - COLXS;
296 <                if (shift >= 8) {
297 <                        l3->r = l3->g = l3->b = 255;
298 <                } else if (shift <= -8) {
301 <                        l3->r = l3->g = l3->b = 0;
302 <                } else if (shift > 0) {
303 <                        c = l4[RED] << shift;
304 <                        l3->r = c > 255 ? 255 : c;
305 <                        c = l4[GRN] << shift;
306 <                        l3->g = c > 255 ? 255 : c;
307 <                        c = l4[BLU] << shift;
308 <                        l3->b = c > 255 ? 255 : c;
309 <                } else if (shift < 0) {
310 <                        l3->r = l4[RED] >> -shift;
311 <                        l3->g = l4[GRN] >> -shift;
312 <                        l3->b = l4[BLU] >> -shift;
313 <                } else {
314 <                        l3->r = l4[RED];
315 <                        l3->g = l4[GRN];
316 <                        l3->b = l4[BLU];
317 <                }
294 >        normcolrs(inline, xmax, 0);
295 >        for (i = 0; i < xmax; i++) {
296 >                l3[i].r = inline[i][RED];
297 >                l3[i].g = inline[i][GRN];
298 >                l3[i].b = inline[i][BLU];
299          }
300   }
301  
# Line 333 | Line 314 | register pixel  *l;
314                          quiterr("seek error in picwriteline");
315          }
316                                                  /* write scanline */
317 <        if (fwrite(l, sizeof(pixel), xmax, outpic->fp) != xmax)
317 >        if (fwrite((char *)l, sizeof(pixel), xmax, outpic->fp) != xmax)
318                  quiterr("write error in picwriteline");
319          if (xmax&1)                             /* on 16-bit boundary */
320                  putc(l[xmax-1], outpic->fp);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines