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.2 by greg, Tue Sep 12 13:04:38 1989 UTC vs.
Revision 1.8 by greg, Wed Nov 7 13:10:33 1990 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                  putchar('\n');
129                  fputresolu(YMAJOR|YDECR, xmax, ymax, stdout);
130                                          /* convert file */
# Line 227 | Line 231 | register FILE  *fp;
231  
232          if (ip != NULL)
233                  if (nidbytes)
234 <                        fread(ip, nidbytes, 1, fp);
234 >                        fread((char *)ip, nidbytes, 1, fp);
235                  else
236                          *ip = '\0';
237          else if (nidbytes)
# Line 300 | Line 304 | register struct hdStruct  *h;
304          h->dataBits = 8;
305          h->imType = 0;
306                                          /* allocate scanline */
307 <        inline = (COLR *)emalloc(xmax*sizeof(COLR));
307 >        inl = (COLR *)emalloc(xmax*sizeof(COLR));
308                                          /* allocate targa data */
309          tarData = taralloc(h);
310  
# Line 320 | Line 324 | struct hdStruct  *hp;
324          register int  i, j;
325  
326                                          /* get color table */
327 <        if ((hp->CMapBits==24 ? fread(map.c3, sizeof(map.c3), 1, stdin) :
328 <                        fread(map.c4, sizeof(map.c4), 1, stdin)) != 1)
327 >        if ((hp->CMapBits==24 ? fread((char *)map.c3,sizeof(map.c3),1,stdin) :
328 >                        fread((char *)map.c4,sizeof(map.c4),1,stdin)) != 1)
329                  quiterr("error reading color table");
330                                          /* convert table */
331          for (i = hp->mapOrig; i < hp->mapOrig+hp->mapLength; i++)
# Line 358 | Line 362 | picreadline3(y, l3)                    /* read in 3-byte scanline */
362   int  y;
363   register rgbpixel  *l3;
364   {
365 <        register BYTE   *l4;
362 <        register int    shift, c;
363 <        int     i;
365 >        register int    i;
366  
367 <        if (inpic->nexty != y) {                                /* find scanline */
367 >        if (inpic->nexty != y) {                        /* find scanline */
368                  if (inpic->bytes_line == 0) {
369                          if (inpic->pos.y[y] == 0) {
370                                  while (inpic->nexty < y) {
371 <                                        if (freadcolrs(inline, xmax, inpic->fp) < 0)
371 >                                        if (freadcolrs(inl, xmax, inpic->fp) < 0)
372                                                  quiterr("read error in picreadline3");
373                                          inpic->pos.y[++inpic->nexty] = ftell(inpic->fp);
374                                  }
# Line 376 | Line 378 | register rgbpixel  *l3;
378                          quiterr("seek error in picreadline3");
379          } else if (inpic->bytes_line == 0 && inpic->pos.y[inpic->nexty] == 0)
380                  inpic->pos.y[inpic->nexty] = ftell(inpic->fp);
381 <        if (freadcolrs(inline, xmax, inpic->fp) < 0)    /* read scanline */
381 >        if (freadcolrs(inl, xmax, inpic->fp) < 0)       /* read scanline */
382                  quiterr("read error in picreadline3");
383          inpic->nexty = y+1;
384                                                          /* convert scanline */
385 <        for (l4=inline[0], i=xmax; i--; l4+=4, l3++) {
386 <                shift = l4[EXP] - COLXS;
387 <                if (shift >= 8) {
388 <                        l3->r = l3->g = l3->b = 255;
389 <                } else if (shift <= -8) {
388 <                        l3->r = l3->g = l3->b = 0;
389 <                } else if (shift > 0) {
390 <                        c = l4[RED] << shift;
391 <                        l3->r = c > 255 ? 255 : c;
392 <                        c = l4[GRN] << shift;
393 <                        l3->g = c > 255 ? 255 : c;
394 <                        c = l4[BLU] << shift;
395 <                        l3->b = c > 255 ? 255 : c;
396 <                } else if (shift < 0) {
397 <                        l3->r = l4[RED] >> -shift;
398 <                        l3->g = l4[GRN] >> -shift;
399 <                        l3->b = l4[BLU] >> -shift;
400 <                } else {
401 <                        l3->r = l4[RED];
402 <                        l3->g = l4[GRN];
403 <                        l3->b = l4[BLU];
404 <                }
385 >        normcolrs(inl, xmax, 0);
386 >        for (i = 0; i < xmax; i++) {
387 >                l3[i].r = inl[i][RED];
388 >                l3[i].g = inl[i][GRN];
389 >                l3[i].b = inl[i][BLU];
390          }
391   }
392  
# Line 410 | Line 395 | picwriteline(y, l)                     /* save output scanline */
395   int  y;
396   pixel  *l;
397   {
398 <        bcopy(l, &tarData[(ymax-1-y)*xmax], xmax*sizeof(pixel));
398 >        bcopy((char *)l, (char *)&tarData[(ymax-1-y)*xmax], xmax*sizeof(pixel));
399   }
400  
401  
# Line 420 | Line 405 | pixel  *d;
405   FILE  *fp;
406   {
407          if (h->dataType == IM_CMAP) {           /* uncompressed */
408 <                if (fwrite(d, h->x*sizeof(pixel), h->y, fp) != h->y)
408 >                if (fwrite((char *)d,h->x*sizeof(pixel),h->y,fp) != h->y)
409                          quiterr("error writing targa file");
410                  return;
411          }
# Line 437 | Line 422 | FILE  *fp;
422          register pixel  *dp;
423  
424          if (h->dataType == IM_CMAP) {           /* uncompressed */
425 <                if (fread(data, h->x*sizeof(pixel), h->y, fp) != h->y)
425 >                if (fread((char *)data,h->x*sizeof(pixel),h->y,fp) != h->y)
426                          goto readerr;
427                  return;
428          }
# Line 480 | Line 465 | colormap  map;
465          register int  i, val;
466  
467          for (i = 0; i < 256; i++) {
468 <                val = pow(i/256.0, 1.0/gamma) * 256.0;
468 >                val = pow((i+0.5)/256.0, 1.0/gamma) * 256.0;
469                  map[0][i] = map[1][i] = map[2][i] = val;
470          }
471   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines