Corrected algorithm, optimized code, and reversed the order of

brightness/contrast operations... brightness is applied first, then
contrast. A contrast of 0 is now /always/ solid medium grey.
This commit is contained in:
Jeff Teunissen 2000-10-24 01:43:35 +00:00
parent b4a29a6766
commit ae76d79b40

View file

@ -108,8 +108,7 @@ void V_UpdatePalette (void)
void
BuildGammaTable (float b, float c)
{
int i, j;
int inf = 0;
int i, inf;
if ((b == 1.0) && (c == 1.0)) {
for (i = 0; i < 256; i++)
@ -117,19 +116,10 @@ BuildGammaTable (float b, float c)
return;
}
for (i=0 ; i<256 ; i++) {
if (!(i == 128)) {
if (i < 128) {
j = i + (int) ((128 - i) * (1 - c));
} else {
j = i + (int) ((i - 128) * (1 - c));
}
} else {
j = i;
}
inf = (j * b); // gamma is brightness now, and positive
inf = bound(0, inf, 255);
gammatable[i] = inf;
for (i=0 ; i<256 ; i++) { // weighted average toward the median, 127
inf = (i * b); // gamma is brightness now, and positive
inf = bound (0, inf, 255);
gammatable[i] = inf + (int) ((127 - inf) * (1 - c));
}
}