Floating-point version of bilinear interpolation
| 243 | |
| 244 | // Floating-point version of bilinear interpolation |
| 245 | u8 upscaleFloat(u8 v00, u8 v10, u8 v01, |
| 246 | u8 v11, float dx, float dy) { |
| 247 | float dx_inv = 1.0f - dx; |
| 248 | float dy_inv = 1.0f - dy; |
| 249 | |
| 250 | // Calculate the weights for each corner |
| 251 | float w00 = dx_inv * dy_inv; |
| 252 | float w10 = dx * dy_inv; |
| 253 | float w01 = dx_inv * dy; |
| 254 | float w11 = dx * dy; |
| 255 | |
| 256 | // Compute the weighted sum |
| 257 | float sum = v00 * w00 + v10 * w10 + v01 * w01 + v11 * w11; |
| 258 | |
| 259 | // Clamp the result to [0, 255] and round |
| 260 | u8 result = static_cast<u8>(sum + 0.5f); |
| 261 | |
| 262 | return result; |
| 263 | } |
| 264 | |
| 265 | // Floating-point version for arbitrary grid sizes |
| 266 | void upscaleArbitraryFloat(const CRGB *input, CRGB *output, u16 inputWidth, |
no test coverage detected