| 10 |  |  | 
| 11 |  | #include "color.h" | 
| 12 |  |  | 
| 13 | < | #define MAXGSHIFT       2               /* maximum shift for gamma table */ | 
| 13 | > | #define MAXGSHIFT       15              /* maximum shift for gamma table */ | 
| 14 |  |  | 
| 15 |  | static BYTE     g_mant[256], g_nexp[256]; | 
| 16 |  |  | 
| 32 |  | /* compute gamb -> colr mapping */ | 
| 33 |  | i = 0; | 
| 34 |  | mult = 256.0; | 
| 35 | < | for (j = 255; j >= 0; j--) { | 
| 36 | < | rept: | 
| 37 | < | g_mant[j] = mult * pow((j+.5)/256.0, g); | 
| 38 | < | if (g_mant[j] < 128) { | 
| 35 | > | for (j = 255; j > 0; j--) { | 
| 36 | > | while ((g_mant[j] = mult * pow(j/256.0, g)) < 128) { | 
| 37 |  | i++; | 
| 38 |  | mult *= 2.0; | 
| 41 | – | goto rept; | 
| 39 |  | } | 
| 40 |  | g_nexp[j] = i; | 
| 41 |  | } | 
| 42 | + | g_mant[0] = 0; | 
| 43 | + | g_nexp[0] = COLXS; | 
| 44 |  | } | 
| 45 |  |  | 
| 46 |  |  | 
| 128 |  | register int    len; | 
| 129 |  | register int    adjust; | 
| 130 |  | { | 
| 131 | + | int     minexp; | 
| 132 | + |  | 
| 133 | + | if (adjust == 0) | 
| 134 | + | return; | 
| 135 | + | minexp = adjust < 0 ? -adjust : 0; | 
| 136 |  | while (len-- > 0) { | 
| 137 | < | scan[0][EXP] += adjust; | 
| 137 | > | if (scan[0][EXP] <= minexp) | 
| 138 | > | scan[0][RED] = scan[0][GRN] = scan[0][BLU] = | 
| 139 | > | scan[0][EXP] = 0; | 
| 140 | > | else | 
| 141 | > | scan[0][EXP] += adjust; | 
| 142 |  | scan++; | 
| 143 |  | } | 
| 144 |  | } |