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.4 by greg, Fri Oct 20 20:36:04 1989 UTC vs.
Revision 1.10 by greg, Thu Apr 18 14:35:38 1991 UTC

# Line 47 | Line 47 | char  *progname;
47  
48   char  errmsg[128];
49  
50 < COLR    *inline;
50 > COLR    *inl;
51  
52   int  xmax, ymax;
53  
# 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 >                fputformat(COLRFMT, stdout);
118                  putchar('\n');
119                  fputresolu(YMAJOR|YDECR, xmax, ymax, stdout);
120                                          /* convert file */
# Line 185 | Line 186 | register struct rasterfile  *h;
186                  p->fp = stdin;
187          else if ((p->fp = fopen(fname, "r")) == NULL)
188                  return(NULL);
189 <                                        /* discard header */
190 <        getheader(p->fp, NULL);
191 <        if (fgetresolu(&xmax, &ymax, p->fp) != (YMAJOR|YDECR))
192 <                quiterr("bad picture size");
189 >                                        /* check header */
190 >        if (checkheader(p->fp, COLRFMT, NULL) < 0 ||
191 >                        fgetresolu(&xmax, &ymax, p->fp) != (YMAJOR|YDECR))
192 >                quiterr("bad picture format");
193          p->nexty = 0;
194          p->bytes_line = 0;              /* variable length lines */
195          p->pos.y = (long *)ecalloc(ymax, sizeof(long));
# Line 203 | Line 204 | register struct rasterfile  *h;
204          h->ras_maptype = RMT_EQUAL_RGB;
205          h->ras_maplength = 256*3;
206                                          /* allocate scanline */
207 <        inline = (COLR *)emalloc(xmax*sizeof(COLR));
207 >        inl = (COLR *)emalloc(xmax*sizeof(COLR));
208  
209          return(p);
210   }
# Line 223 | Line 224 | register struct rasterfile  *h;
224          else if ((p->fp = fopen(fname, "w")) == NULL)
225                  return(NULL);
226                                          /* write header */
227 <        fwrite(h, sizeof(*h), 1, p->fp);
227 >        fwrite((char *)h, sizeof(*h), 1, p->fp);
228          p->nexty = -1;                  /* needs color map */
229          p->bytes_line = h->ras_width;
230          p->pos.b = 0;
# Line 243 | Line 244 | struct rasterfile  *h;
244          scanline = (COLR *)emalloc(xmax*sizeof(COLR));
245                                          /* get color table */
246          for (i = 0; i < 3; i ++)
247 <                if (fread(cmap[i], h->ras_maplength/3, 1, stdin) != 1)
247 >                if (fread((char *)cmap[i], h->ras_maplength/3, 1, stdin) != 1)
248                          quiterr("error reading color table");
249                                          /* convert table */
250          for (i = 0; i < h->ras_maplength/3; i++)
# Line 277 | Line 278 | register rgbpixel  *l3;
278                  if (inpic->bytes_line == 0) {
279                          if (inpic->pos.y[y] == 0) {
280                                  while (inpic->nexty < y) {
281 <                                        if (freadcolrs(inline, xmax, inpic->fp) < 0)
281 >                                        if (freadcolrs(inl, xmax, inpic->fp) < 0)
282                                                  quiterr("read error in picreadline3");
283                                          inpic->pos.y[++inpic->nexty] = ftell(inpic->fp);
284                                  }
# Line 287 | Line 288 | register rgbpixel  *l3;
288                          quiterr("seek error in picreadline3");
289          } else if (inpic->bytes_line == 0 && inpic->pos.y[inpic->nexty] == 0)
290                  inpic->pos.y[inpic->nexty] = ftell(inpic->fp);
291 <        if (freadcolrs(inline, xmax, inpic->fp) < 0)    /* read scanline */
291 >        if (freadcolrs(inl, xmax, inpic->fp) < 0)       /* read scanline */
292                  quiterr("read error in picreadline3");
293          inpic->nexty = y+1;
294                                                          /* convert scanline */
295 <        normcolrs(inline, xmax);
295 >        normcolrs(inl, xmax, 0);
296          for (i = 0; i < xmax; i++) {
297 <                l3[i].r = inline[i][RED];
298 <                l3[i].g = inline[i][GRN];
299 <                l3[i].b = inline[i][BLU];
297 >                l3[i].r = inl[i][RED];
298 >                l3[i].g = inl[i][GRN];
299 >                l3[i].b = inl[i][BLU];
300          }
301   }
302  
# Line 314 | Line 315 | register pixel  *l;
315                          quiterr("seek error in picwriteline");
316          }
317                                                  /* write scanline */
318 <        if (fwrite(l, sizeof(pixel), xmax, outpic->fp) != xmax)
318 >        if (fwrite((char *)l, sizeof(pixel), xmax, outpic->fp) != xmax)
319                  quiterr("write error in picwriteline");
320          if (xmax&1)                             /* on 16-bit boundary */
321                  putc(l[xmax-1], outpic->fp);
# Line 349 | Line 350 | colormap  map;
350          register int  i, val;
351  
352          for (i = 0; i < 256; i++) {
353 <                val = pow(i/256.0, 1.0/gamma) * 256.0;
353 >                val = pow((i+0.5)/256.0, 1.0/gamma) * 256.0;
354                  map[0][i] = map[1][i] = map[2][i] = val;
355          }
356   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines