| 172 | // Computes: clamp(round(pow(x/255, gamma) * 255), 0, 255) |
| 173 | |
| 174 | constexpr u8 eval(u8 x, u32 gamma_raw) FL_NOEXCEPT { |
| 175 | return x == 0 ? static_cast<u8>(0) |
| 176 | : x == 255 ? static_cast<u8>(255) |
| 177 | : static_cast<u8>( |
| 178 | (pow_fp( |
| 179 | static_cast<u32>((static_cast<u64>(x) << FRAC) / 255), |
| 180 | gamma_raw |
| 181 | ) * 255ULL + (SCALE >> 1)) >> FRAC |
| 182 | ); |
| 183 | } |
| 184 | |
| 185 | // ---- 16-bit gamma correction for a single pixel value ---- |
| 186 | // Computes: clamp(round(pow(x/255, gamma) * 65535), 0, 65535) |
no test coverage detected