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.8 by greg, Fri Oct 20 20:35:22 1989 UTC vs.
Revision 1.10 by greg, Fri Jan 26 08:21:45 1990 UTC

# Line 367 | Line 367 | register COLR  clr;
367   }
368  
369  
370 < normcolrs(scan, len)            /* normalize a scanline of colrs */
370 > normcolrs(scan, len, adjust)    /* normalize a scanline of colrs */
371   register COLR  *scan;
372   int  len;
373 + int  adjust;
374   {
375          register int  c;
376          register int  shift;
377  
378          while (len-- > 0) {
379 <                shift = scan[0][EXP] - COLXS;
379 >                shift = scan[0][EXP] + adjust - COLXS;
380                  if (shift > 0) {
381 <                        if (shift >= 8) {
381 >                        if (shift > 8) {
382                                  scan[0][RED] =
383                                  scan[0][GRN] =
384                                  scan[0][BLU] = 255;
385                          } else {
386 <                                c = scan[0][RED] << shift;
386 >                                shift--;
387 >                                c = (scan[0][RED]<<1 | 1) << shift;
388                                  scan[0][RED] = c > 255 ? 255 : c;
389 <                                c = scan[0][GRN] << shift;
389 >                                c = (scan[0][GRN]<<1 | 1) << shift;
390                                  scan[0][GRN] = c > 255 ? 255 : c;
391 <                                c = scan[0][BLU] << shift;
391 >                                c = (scan[0][BLU]<<1 | 1) << shift;
392                                  scan[0][BLU] = c > 255 ? 255 : c;
393                          }
394                  } else if (shift < 0) {
395 <                        if (shift <= -8) {
395 >                        if (shift < -8) {
396                                  scan[0][RED] =
397                                  scan[0][GRN] =
398                                  scan[0][BLU] = 0;
399                          } else {
400 <                                scan[0][RED] = scan[0][RED] >> -shift;
401 <                                scan[0][GRN] = scan[0][GRN] >> -shift;
402 <                                scan[0][BLU] = scan[0][BLU] >> -shift;
400 >                                shift = -1-shift;
401 >                                scan[0][RED] = ((scan[0][RED]>>shift)+1)>>1;
402 >                                scan[0][GRN] = ((scan[0][GRN]>>shift)+1)>>1;
403 >                                scan[0][BLU] = ((scan[0][BLU]>>shift)+1)>>1;
404                          }
405                  }
406 <                scan[0][EXP] = COLXS;
406 >                scan[0][EXP] = COLXS - adjust;
407                  scan++;
408          }
409   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines