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.9 by greg, Mon Nov 6 15:10:24 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 + normcolrs(scan, len)            /* normalize a scanline of colrs */
371 + register COLR  *scan;
372 + int  len;
373 + {
374 +        register int  c;
375 +        register int  shift;
376 +
377 +        while (len-- > 0) {
378 +                shift = scan[0][EXP] - COLXS;
379 +                if (shift > 0) {
380 +                        if (shift > 8) {
381 +                                scan[0][RED] =
382 +                                scan[0][GRN] =
383 +                                scan[0][BLU] = 255;
384 +                        } else {
385 +                                shift--;
386 +                                c = (scan[0][RED]<<1 | 1) << shift;
387 +                                scan[0][RED] = c > 255 ? 255 : c;
388 +                                c = (scan[0][GRN]<<1 | 1) << shift;
389 +                                scan[0][GRN] = c > 255 ? 255 : c;
390 +                                c = (scan[0][BLU]<<1 | 1) << shift;
391 +                                scan[0][BLU] = c > 255 ? 255 : c;
392 +                        }
393 +                } else if (shift < 0) {
394 +                        if (shift < -8) {
395 +                                scan[0][RED] =
396 +                                scan[0][GRN] =
397 +                                scan[0][BLU] = 0;
398 +                        } else {
399 +                                shift = -1-shift;
400 +                                scan[0][RED] = ((scan[0][RED]>>shift)+1)>>1;
401 +                                scan[0][GRN] = ((scan[0][GRN]>>shift)+1)>>1;
402 +                                scan[0][BLU] = ((scan[0][BLU]>>shift)+1)>>1;
403 +                        }
404 +                }
405 +                scan[0][EXP] = COLXS;
406 +                scan++;
407 +        }
408 + }
409 +
410 +
411 + bigdiff(c1, c2, md)                     /* c1 delta c2 > md? */
412 + register COLOR  c1, c2;
413 + double  md;
414 + {
415 +        register int  i;
416 +
417 +        for (i = 0; i < 3; i++)
418 +                if (colval(c1,i)-colval(c2,i) > md*colval(c2,i) ||
419 +                        colval(c2,i)-colval(c1,i) > md*colval(c1,i))
420 +                        return(1);
421 +        return(0);
422   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines