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

◆ bilinearInterpolatePowerOf2()

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

Definition at line 222 of file upscale.cpp.

223 {
224 u16 dx_inv = 256 - dx; // 0 to 256
225 u16 dy_inv = 256 - dy; // 0 to 256
226
227 // Scale down weights to fit into u16
228 u16 w00 = (dx_inv * dy_inv) >> 8; // Max value 256
229 u16 w10 = (dx * dy_inv) >> 8;
230 u16 w01 = (dx_inv * dy) >> 8;
231 u16 w11 = (dx * dy) >> 8;
232
233 // Sum of weights should be approximately 256
234 u16 weight_sum = w00 + w10 + w01 + w11;
235
236 // Compute the weighted sum of pixel values
237 u16 sum = v00 * w00 + v10 * w10 + v01 * w01 + v11 * w11;
238
239 // Normalize the result
240 u8 result = (sum + (weight_sum >> 1)) / weight_sum;
241
242 return result;
243}
Result type for promise operations.
unsigned char u8
Definition int.h:17

Referenced by upscalePowerOf2(), and upscaleRectangularPowerOf2().

+ Here is the caller graph for this function: