MCPcopy Create free account
hub / github.com/FastLED/FastLED / upscaleFloat

Function upscaleFloat

src/fl/gfx/upscale.cpp.hpp:245–263  ·  view source on GitHub ↗

Floating-point version of bilinear interpolation

Source from the content-addressed store, hash-verified

243
244// Floating-point version of bilinear interpolation
245u8 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
266void upscaleArbitraryFloat(const CRGB *input, CRGB *output, u16 inputWidth,

Callers 2

upscaleArbitraryFloatFunction · 0.85
expandMethod · 0.85

Calls 4

getTotalMethod · 0.80
getWidthMethod · 0.45
getHeightMethod · 0.45
mapToIndexMethod · 0.45

Tested by

no test coverage detected