Vá para o código-fonte deste arquivo.
Funções | |
| void | calcPreIntTable (int imgsize, float thickness, unsigned char *data, unsigned char *table) |
| void calcPreIntTable | ( | int | imgsize, | |
| float | thickness, | |||
| unsigned char * | data, | |||
| unsigned char * | table | |||
| ) |
Definição na linha 19 do arquivo preint.c.
00021 { 00022 int sb, sf, i, j, n, base1, base2, offset; 00023 double stepWidth, s, temp; 00024 double rgba[4], rgbac[4]; 00025 00026 g.data = data; 00027 00028 for (sb = 0; sb < imgsize; sb++) { 00029 for (sf = 0; sf <= sb; sf++) { 00030 n = MIN_INT_STEPS + ADD_LOOKUP_STEPS * abs(sb - sf); 00031 00032 stepWidth = thickness/n; 00033 memset(rgba, 0, sizeof(rgba)); 00034 00035 for (i = 0; i < n; i++) { 00036 s = sf + (sb - sf) * (double)i/n; 00037 offset = sf != sb; 00038 00039 #if 0 00040 fprintf(stderr, "sb = %i; sf = %i; n = %i; s = %lf\n", 00041 sb, sf, n, s); 00042 #endif 00043 00044 rgbac[3] = stepWidth/255.0 * 00045 LERP(VAL(s, 3), VAL(s + offset, 3), s - floor(s)); 00046 #if 0 00047 fprintf(stderr, "%f\n", LERP(VAL(s, 3), VAL(s + 1, 3), s - 00048 floor(s))/255.0); 00049 #endif 00050 00051 /* Standard optical model: RGB densities are multiplied with 00052 * opacity density */ 00053 temp = exp(-rgba[3]) * rgbac[3]/255.0; 00054 #if 0 00055 fprintf(stderr, "%f %f\n", exp(-rgba[3]), rgba[3]); 00056 #endif 00057 for (j = 0; j < 3; j++) { 00058 rgbac[j] = temp * 00059 LERP(VAL(s, j), VAL(s + offset, j), 00060 s - floor(s)); 00061 rgba[j] += rgbac[j]; 00062 } 00063 rgba[3] += rgbac[3]; 00064 } 00065 00066 base1 = (sb * imgsize + sf) * 4; 00067 base2 = (sf * imgsize + sb) * 4; 00068 for (i = 0; i < 3; i ++) { 00069 if (rgba[i] > 1.0) { 00070 rgba[i] = 1.0; 00071 } 00072 table[base1++] = table[base2++] = (unsigned char)(rgba[i] * 255.99); 00073 } 00074 table[base1] = table[base2] = (unsigned char)((1.0 - exp(-rgba[3])) * 255.99); 00075 } 00076 } 00077 }
1.6.1