mirror of
https://git.code.sf.net/p/quake/newtree
synced 2025-02-08 15:22:07 +00:00
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:
parent
b4a29a6766
commit
ae76d79b40
1 changed files with 5 additions and 15 deletions
|
@ -108,8 +108,7 @@ void V_UpdatePalette (void)
|
||||||
void
|
void
|
||||||
BuildGammaTable (float b, float c)
|
BuildGammaTable (float b, float c)
|
||||||
{
|
{
|
||||||
int i, j;
|
int i, inf;
|
||||||
int inf = 0;
|
|
||||||
|
|
||||||
if ((b == 1.0) && (c == 1.0)) {
|
if ((b == 1.0) && (c == 1.0)) {
|
||||||
for (i = 0; i < 256; i++)
|
for (i = 0; i < 256; i++)
|
||||||
|
@ -117,19 +116,10 @@ BuildGammaTable (float b, float c)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i=0 ; i<256 ; i++) {
|
for (i=0 ; i<256 ; i++) { // weighted average toward the median, 127
|
||||||
if (!(i == 128)) {
|
inf = (i * b); // gamma is brightness now, and positive
|
||||||
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);
|
inf = bound (0, inf, 255);
|
||||||
gammatable[i] = inf;
|
gammatable[i] = inf + (int) ((127 - inf) * (1 - c));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue