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

Comparing ray/src/px/ra_t8.c (file contents):
Revision 1.3 by greg, Fri Oct 20 20:36:06 1989 UTC vs.
Revision 1.9 by greg, Thu Apr 18 14:35:45 1991 UTC

# Line 19 | Line 19 | static char SCCSid[] = "$SunId$ LBL";
19  
20   #include  "targa.h"
21  
22 + #ifndef  BSD
23 + #define  bcopy(s,d,n)           (void)memcpy(d,s,n)
24 + extern char  *memcpy();
25 + #endif
26                          /* descriptor for a picture file or frame buffer */
27   typedef struct {
28          char    *name;                  /* file name */
# Line 55 | Line 59 | char  *progname;
59  
60   char  errmsg[128];
61  
62 < COLR    *inline;
62 > COLR    *inl;
63  
64   pixel   *tarData;
65  
# Line 120 | Line 124 | char  *argv[];
124                          quiterr(errmsg);
125                  }
126                                          /* put header */
127 <                printargs(argc, argv, stdout);
127 >                printargs(i, argv, stdout);
128 >                fputformat(COLRFMT, stdout);
129                  putchar('\n');
130                  fputresolu(YMAJOR|YDECR, xmax, ymax, stdout);
131                                          /* convert file */
# Line 227 | Line 232 | register FILE  *fp;
232  
233          if (ip != NULL)
234                  if (nidbytes)
235 <                        fread(ip, nidbytes, 1, fp);
235 >                        fread((char *)ip, nidbytes, 1, fp);
236                  else
237                          *ip = '\0';
238          else if (nidbytes)
# Line 278 | Line 283 | register struct hdStruct  *h;
283                  p->fp = stdin;
284          else if ((p->fp = fopen(fname, "r")) == NULL)
285                  return(NULL);
286 <                                        /* discard header */
287 <        getheader(p->fp, NULL);
288 <        if (fgetresolu(&xmax, &ymax, p->fp) != (YMAJOR|YDECR))
289 <                quiterr("bad picture size");
286 >                                        /* get header info. */
287 >        if (checkheader(p->fp, COLRFMT, NULL) < 0 ||
288 >                        fgetresolu(&xmax, &ymax, p->fp) != (YMAJOR|YDECR))
289 >                quiterr("bad picture format");
290          p->nexty = 0;
291          p->bytes_line = 0;              /* variable length lines */
292          p->pos.y = (long *)ecalloc(ymax, sizeof(long));
# Line 300 | Line 305 | register struct hdStruct  *h;
305          h->dataBits = 8;
306          h->imType = 0;
307                                          /* allocate scanline */
308 <        inline = (COLR *)emalloc(xmax*sizeof(COLR));
308 >        inl = (COLR *)emalloc(xmax*sizeof(COLR));
309                                          /* allocate targa data */
310          tarData = taralloc(h);
311  
# Line 320 | Line 325 | struct hdStruct  *hp;
325          register int  i, j;
326  
327                                          /* get color table */
328 <        if ((hp->CMapBits==24 ? fread(map.c3, sizeof(map.c3), 1, stdin) :
329 <                        fread(map.c4, sizeof(map.c4), 1, stdin)) != 1)
328 >        if ((hp->CMapBits==24 ? fread((char *)map.c3,sizeof(map.c3),1,stdin) :
329 >                        fread((char *)map.c4,sizeof(map.c4),1,stdin)) != 1)
330                  quiterr("error reading color table");
331                                          /* convert table */
332          for (i = hp->mapOrig; i < hp->mapOrig+hp->mapLength; i++)
# Line 364 | Line 369 | register rgbpixel  *l3;
369                  if (inpic->bytes_line == 0) {
370                          if (inpic->pos.y[y] == 0) {
371                                  while (inpic->nexty < y) {
372 <                                        if (freadcolrs(inline, xmax, inpic->fp) < 0)
372 >                                        if (freadcolrs(inl, xmax, inpic->fp) < 0)
373                                                  quiterr("read error in picreadline3");
374                                          inpic->pos.y[++inpic->nexty] = ftell(inpic->fp);
375                                  }
# Line 374 | Line 379 | register rgbpixel  *l3;
379                          quiterr("seek error in picreadline3");
380          } else if (inpic->bytes_line == 0 && inpic->pos.y[inpic->nexty] == 0)
381                  inpic->pos.y[inpic->nexty] = ftell(inpic->fp);
382 <        if (freadcolrs(inline, xmax, inpic->fp) < 0)    /* read scanline */
382 >        if (freadcolrs(inl, xmax, inpic->fp) < 0)       /* read scanline */
383                  quiterr("read error in picreadline3");
384          inpic->nexty = y+1;
385                                                          /* convert scanline */
386 <        normcolrs(inline, xmax);
386 >        normcolrs(inl, xmax, 0);
387          for (i = 0; i < xmax; i++) {
388 <                l3[i].r = inline[i][RED];
389 <                l3[i].g = inline[i][GRN];
390 <                l3[i].b = inline[i][BLU];
388 >                l3[i].r = inl[i][RED];
389 >                l3[i].g = inl[i][GRN];
390 >                l3[i].b = inl[i][BLU];
391          }
392   }
393  
# Line 391 | Line 396 | picwriteline(y, l)                     /* save output scanline */
396   int  y;
397   pixel  *l;
398   {
399 <        bcopy(l, &tarData[(ymax-1-y)*xmax], xmax*sizeof(pixel));
399 >        bcopy((char *)l, (char *)&tarData[(ymax-1-y)*xmax], xmax*sizeof(pixel));
400   }
401  
402  
# Line 401 | Line 406 | pixel  *d;
406   FILE  *fp;
407   {
408          if (h->dataType == IM_CMAP) {           /* uncompressed */
409 <                if (fwrite(d, h->x*sizeof(pixel), h->y, fp) != h->y)
409 >                if (fwrite((char *)d,h->x*sizeof(pixel),h->y,fp) != h->y)
410                          quiterr("error writing targa file");
411                  return;
412          }
# Line 418 | Line 423 | FILE  *fp;
423          register pixel  *dp;
424  
425          if (h->dataType == IM_CMAP) {           /* uncompressed */
426 <                if (fread(data, h->x*sizeof(pixel), h->y, fp) != h->y)
426 >                if (fread((char *)data,h->x*sizeof(pixel),h->y,fp) != h->y)
427                          goto readerr;
428                  return;
429          }
# Line 461 | Line 466 | colormap  map;
466          register int  i, val;
467  
468          for (i = 0; i < 256; i++) {
469 <                val = pow(i/256.0, 1.0/gamma) * 256.0;
469 >                val = pow((i+0.5)/256.0, 1.0/gamma) * 256.0;
470                  map[0][i] = map[1][i] = map[2][i] = val;
471          }
472   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines