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

◆ bilinearInterpolatePowerOf2()

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

Definition at line 136 of file upscale.cpp.

137 {
138 uint16_t dx_inv = 256 - dx; // 0 to 256
139 uint16_t dy_inv = 256 - dy; // 0 to 256
140
141 // Scale down weights to fit into uint16_t
142 uint16_t w00 = (dx_inv * dy_inv) >> 8; // Max value 256
143 uint16_t w10 = (dx * dy_inv) >> 8;
144 uint16_t w01 = (dx_inv * dy) >> 8;
145 uint16_t w11 = (dx * dy) >> 8;
146
147 // Sum of weights should be approximately 256
148 uint16_t weight_sum = w00 + w10 + w01 + w11;
149
150 // Compute the weighted sum of pixel values
151 uint16_t sum = v00 * w00 + v10 * w10 + v01 * w01 + v11 * w11;
152
153 // Normalize the result
154 uint8_t result = (sum + (weight_sum >> 1)) / weight_sum;
155
156 return result;
157}

Referenced by upscalePowerOf2().

+ Here is the caller graph for this function: