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

Function bilinearInterpolate

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

Source from the content-addressed store, hash-verified

148 }
149}
150u8 bilinearInterpolate(u8 v00, u8 v10, u8 v01, u8 v11,
151 u16 dx, u16 dy) {
152 u16 dx_inv = 256 - dx;
153 u16 dy_inv = 256 - dy;
154
155 u32 w00 = (u32)dx_inv * dy_inv;
156 u32 w10 = (u32)dx * dy_inv;
157 u32 w01 = (u32)dx_inv * dy;
158 u32 w11 = (u32)dx * dy;
159
160 u32 sum = v00 * w00 + v10 * w10 + v01 * w01 + v11 * w11;
161
162 // Normalize the result by dividing by 65536 (shift right by 16 bits),
163 // with rounding
164 u8 result = (u8)((sum + 32768) >> 16);
165
166 return result;
167}
168
169void upscalePowerOf2(const CRGB *input, CRGB *output, u8 inputWidth,
170 u8 inputHeight, const XYMap& xyMap) {

Callers 2

upscaleRectangularFunction · 0.85
upscaleArbitraryFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected