FastLED 3.9.15
Loading...
Searching...
No Matches

◆ bilinearInterpolate()

u8 fl::bilinearInterpolate ( u8 v00,
u8 v10,
u8 v01,
u8 v11,
u16 dx,
u16 dy )

Definition at line 150 of file upscale.cpp.hpp.

151 {
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}
unsigned char u8
Definition stdint.h:131
expected< T, E > result
Alias for expected (Rust-style naming)
Definition result.h:31

Referenced by upscaleArbitrary(), and upscaleRectangular().

+ Here is the caller graph for this function: