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

◆ upscaleArbitraryFloat()

void fl::upscaleArbitraryFloat ( const CRGB * input,
CRGB * output,
u16 inputWidth,
u16 inputHeight,
const XYMap & xyMap )

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

267 {
268 u16 n = xyMap.getTotal();
269 u16 outputWidth = xyMap.getWidth();
270 u16 outputHeight = xyMap.getHeight();
271
272 for (u16 y = 0; y < outputHeight; y++) {
273 for (u16 x = 0; x < outputWidth; x++) {
274 // Map output pixel to input grid position
275 float fx =
276 static_cast<float>(x) * (inputWidth - 1) / (outputWidth - 1);
277 float fy =
278 static_cast<float>(y) * (inputHeight - 1) / (outputHeight - 1);
279
280 u16 ix = static_cast<u16>(fx);
281 u16 iy = static_cast<u16>(fy);
282 float dx = fx - ix;
283 float dy = fy - iy;
284
285 u16 ix1 = (ix + 1 < inputWidth) ? ix + 1 : ix;
286 u16 iy1 = (iy + 1 < inputHeight) ? iy + 1 : iy;
287
288 u16 i00 = iy * inputWidth + ix;
289 u16 i10 = iy * inputWidth + ix1;
290 u16 i01 = iy1 * inputWidth + ix;
291 u16 i11 = iy1 * inputWidth + ix1;
292
293 CRGB c00 = input[i00];
294 CRGB c10 = input[i10];
295 CRGB c01 = input[i01];
296 CRGB c11 = input[i11];
297
298 CRGB result;
299 result.r =
300 upscaleFloat(c00.r, c10.r, c01.r, c11.r, dx, dy);
301 result.g =
302 upscaleFloat(c00.g, c10.g, c01.g, c11.g, dx, dy);
303 result.b =
304 upscaleFloat(c00.b, c10.b, c01.b, c11.b, dx, dy);
305
306 u16 idx = xyMap.mapToIndex(x, y);
307 if (idx < n) {
308 output[idx] = result;
309 }
310 }
311 }
312}
fl::XYMap xyMap
expected< T, E > result
Alias for expected (Rust-style naming)
Definition result.h:31
u8 upscaleFloat(u8 v00, u8 v10, u8 v01, u8 v11, float dx, float dy)
Representation of an 8-bit RGB pixel (Red, Green, Blue)
Definition crgb.h:38

References upscaleFloat(), x, xyMap, and y.

+ Here is the call graph for this function: