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

◆ upscaleFloat() [2/2]

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

Definition at line 160 of file upscale.cpp.

161 {
162 float dx_inv = 1.0f - dx;
163 float dy_inv = 1.0f - dy;
164
165 // Calculate the weights for each corner
166 float w00 = dx_inv * dy_inv;
167 float w10 = dx * dy_inv;
168 float w01 = dx_inv * dy;
169 float w11 = dx * dy;
170
171 // Compute the weighted sum
172 float sum = v00 * w00 + v10 * w10 + v01 * w01 + v11 * w11;
173
174 // Clamp the result to [0, 255] and round
175 uint8_t result = static_cast<uint8_t>(sum + 0.5f);
176
177 return result;
178}

Referenced by bilinearInterpolateFloat(), fl::ScaleUp::expand(), upscaleArbitraryFloat(), and upscaleFloat().

+ Here is the caller graph for this function: