comparison src/video/SDL_gamma.c @ 3040:62d4992e5a92

indent
author Sam Lantinga <slouken@libsdl.org>
date Wed, 14 Jan 2009 04:25:32 +0000
parents 7e30c2dc7783
children 4b594623401b
comparison
equal deleted inserted replaced
3039:829043b363d1 3040:62d4992e5a92
48 /* Calculate a real gamma ramp */ 48 /* Calculate a real gamma ramp */
49 { 49 {
50 int value; 50 int value;
51 gamma = 1.0f / gamma; 51 gamma = 1.0f / gamma;
52 for (i = 0; i < 256; ++i) { 52 for (i = 0; i < 256; ++i) {
53 value = (int) (SDL_pow((double) i / 256.0, gamma) * 65535.0 + 0.5); 53 value =
54 (int) (SDL_pow((double) i / 256.0, gamma) * 65535.0 + 0.5);
54 if (value > 65535) { 55 if (value > 65535) {
55 value = 65535; 56 value = 65535;
56 } 57 }
57 ramp[i] = (Uint16) value; 58 ramp[i] = (Uint16) value;
58 } 59 }
71 *gamma = 1.0; 72 *gamma = 1.0;
72 for (i = 1; i < 256; ++i) { 73 for (i = 1; i < 256; ++i) {
73 if ((ramp[i] != 0) && (ramp[i] != 65535)) { 74 if ((ramp[i] != 0) && (ramp[i] != 65535)) {
74 double B = (double) i / 256.0; 75 double B = (double) i / 256.0;
75 double A = ramp[i] / 65535.0; 76 double A = ramp[i] / 65535.0;
76 sum += (float) (SDL_log(A) / SDL_log(B)); 77 sum += (float) (SDL_log(A) / SDL_log(B));
77 count++; 78 count++;
78 } 79 }
79 } 80 }
80 if (count && sum > 0.0f) { 81 if (count && sum > 0.0f) {
81 *gamma = 1.0f / (sum / count); 82 *gamma = 1.0f / (sum / count);