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

◆ upscaleFloat() [1/2]

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

Definition at line 316 of file upscale.cpp.

317 {
318 u8 outputWidth = xyMap.getWidth();
319 u8 outputHeight = xyMap.getHeight();
320 if (outputWidth != xyMap.getWidth() || outputHeight != xyMap.getHeight()) {
321 // xyMap has width and height that do not fit in a u8.
322 return;
323 }
324 u16 n = xyMap.getTotal();
325
326 for (u8 y = 0; y < outputHeight; y++) {
327 for (u8 x = 0; x < outputWidth; x++) {
328 // Map output pixel to input grid position
329 float fx =
330 static_cast<float>(x) * (inputWidth - 1) / (outputWidth - 1);
331 float fy =
332 static_cast<float>(y) * (inputHeight - 1) / (outputHeight - 1);
333
334 u8 ix = static_cast<u8>(fx);
335 u8 iy = static_cast<u8>(fy);
336 float dx = fx - ix;
337 float dy = fy - iy;
338
339 u8 ix1 = (ix + 1 < inputWidth) ? ix + 1 : ix;
340 u8 iy1 = (iy + 1 < inputHeight) ? iy + 1 : iy;
341
342 u16 i00 = iy * inputWidth + ix;
343 u16 i10 = iy * inputWidth + ix1;
344 u16 i01 = iy1 * inputWidth + ix;
345 u16 i11 = iy1 * inputWidth + ix1;
346
347 CRGB c00 = input[i00];
348 CRGB c10 = input[i10];
349 CRGB c01 = input[i01];
350 CRGB c11 = input[i11];
351
352 CRGB result;
353 result.r =
354 upscaleFloat(c00.r, c10.r, c01.r, c11.r, dx, dy);
355 result.g =
356 upscaleFloat(c00.g, c10.g, c01.g, c11.g, dx, dy);
357 result.b =
358 upscaleFloat(c00.b, c10.b, c01.b, c11.b, dx, dy);
359
360 u16 idx = xyMap.mapToIndex(x, y);
361 if (idx < n) {
362 output[idx] = result;
363 }
364 }
365 }
366}
int y
Definition simple.h:93
int x
Definition simple.h:92
fl::XYMap xyMap
Definition ColorBoost.h:61
unsigned char u8
Definition int.h:17
u8 upscaleFloat(u8 v00, u8 v10, u8 v01, u8 v11, float dx, float dy)
Definition upscale.cpp:246
Representation of an RGB pixel (Red, Green, Blue)
Definition crgb.h:86

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

+ Here is the call graph for this function: