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

Comparing ray/src/common/color.c (file contents):
Revision 1.5 by greg, Wed Sep 13 16:35:14 1989 UTC vs.
Revision 1.6 by greg, Fri Oct 20 16:45:26 1989 UTC

# Line 354 | Line 354 | colr_color(col, clr)           /* convert short to float color
354   register COLOR  col;
355   register COLR  clr;
356   {
357 <        double  ldexp(), f;
357 >        double  f;
358          
359          if (clr[EXP] == 0)
360                  col[RED] = col[GRN] = col[BLU] = 0.0;
# Line 364 | Line 364 | register COLR  clr;
364                  col[GRN] = (clr[GRN] + 0.5)*f;
365                  col[BLU] = (clr[BLU] + 0.5)*f;
366          }
367 + }
368 +
369 +
370 + int
371 + colr_norm(clr, nclr)            /* normalize a short color, return shift */
372 + COLR  clr, nclr;
373 + {
374 +        register int  c;
375 +        register int  shift = clr[EXP]-COLXS;
376 +
377 +        if (shift > 0) {
378 +                if (shift >= 8) {
379 +                        nclr[RED] = nclr[GRN] = nclr[BLU] = 255;
380 +                } else {
381 +                        c = clr[RED] << shift;
382 +                        nclr[RED] = c > 255 ? 255 : c;
383 +                        c = clr[GRN] << shift;
384 +                        nclr[GRN] = c > 255 ? 255 : c;
385 +                        c = clr[BLU] << shift;
386 +                        nclr[BLU] = c > 255 ? 255 : c;
387 +                }
388 +        } else if (shift < 0) {
389 +                if (shift <= -8) {
390 +                        nclr[RED] = nclr[GRN] = nclr[BLU] = 0;
391 +                } else {
392 +                        nclr[RED] = clr[RED] >> -shift;
393 +                        nclr[GRN] = clr[GRN] >> -shift;
394 +                        nclr[BLU] = clr[BLU] >> -shift;
395 +                }
396 +        } else {
397 +                nclr[RED] = clr[RED];
398 +                nclr[GRN] = clr[GRN];
399 +                nclr[BLU] = clr[BLU];
400 +        }
401 +        nclr[EXP] = COLXS;
402 +        return(shift);
403   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines