for (int i=0; i< 255; i++) { lookup[i<<8] = i; for (int j=1; j<255; j++) lookup[(i<<8)+j] = uint8clamp((i * 255 + j / 2) / j); }