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.9 by greg, Mon Nov 6 15:10:24 1989 UTC

# Line 377 | Line 377 | int  len;
377          while (len-- > 0) {
378                  shift = scan[0][EXP] - COLXS;
379                  if (shift > 0) {
380 <                        if (shift >= 8) {
380 >                        if (shift > 8) {
381                                  scan[0][RED] =
382                                  scan[0][GRN] =
383                                  scan[0][BLU] = 255;
384                          } else {
385 <                                c = scan[0][RED] << shift;
385 >                                shift--;
386 >                                c = (scan[0][RED]<<1 | 1) << shift;
387                                  scan[0][RED] = c > 255 ? 255 : c;
388 <                                c = scan[0][GRN] << shift;
388 >                                c = (scan[0][GRN]<<1 | 1) << shift;
389                                  scan[0][GRN] = c > 255 ? 255 : c;
390 <                                c = scan[0][BLU] << shift;
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) {
394 >                        if (shift < -8) {
395                                  scan[0][RED] =
396                                  scan[0][GRN] =
397                                  scan[0][BLU] = 0;
398                          } else {
399 <                                scan[0][RED] = scan[0][RED] >> -shift;
400 <                                scan[0][GRN] = scan[0][GRN] >> -shift;
401 <                                scan[0][BLU] = scan[0][BLU] >> -shift;
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;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines