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

◆ upscaleFloat() [1/2]

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

Definition at line 230 of file upscale.cpp.

231 {
232 uint8_t outputWidth = xyMap.getWidth();
233 uint8_t outputHeight = xyMap.getHeight();
234 if (outputWidth != xyMap.getWidth() || outputHeight != xyMap.getHeight()) {
235 // xyMap has width and height that do not fit in a uint8_t.
236 return;
237 }
238 uint16_t n = xyMap.getTotal();
239
240 for (uint8_t y = 0; y < outputHeight; y++) {
241 for (uint8_t x = 0; x < outputWidth; x++) {
242 // Map output pixel to input grid position
243 float fx =
244 static_cast<float>(x) * (inputWidth - 1) / (outputWidth - 1);
245 float fy =
246 static_cast<float>(y) * (inputHeight - 1) / (outputHeight - 1);
247
248 uint8_t ix = static_cast<uint8_t>(fx);
249 uint8_t iy = static_cast<uint8_t>(fy);
250 float dx = fx - ix;
251 float dy = fy - iy;
252
253 uint8_t ix1 = (ix + 1 < inputWidth) ? ix + 1 : ix;
254 uint8_t iy1 = (iy + 1 < inputHeight) ? iy + 1 : iy;
255
256 uint16_t i00 = iy * inputWidth + ix;
257 uint16_t i10 = iy * inputWidth + ix1;
258 uint16_t i01 = iy1 * inputWidth + ix;
259 uint16_t i11 = iy1 * inputWidth + ix1;
260
261 CRGB c00 = input[i00];
262 CRGB c10 = input[i10];
263 CRGB c01 = input[i01];
264 CRGB c11 = input[i11];
265
266 CRGB result;
267 result.r =
268 upscaleFloat(c00.r, c10.r, c01.r, c11.r, dx, dy);
269 result.g =
270 upscaleFloat(c00.g, c10.g, c01.g, c11.g, dx, dy);
271 result.b =
272 upscaleFloat(c00.b, c10.b, c01.b, c11.b, dx, dy);
273
274 uint16_t idx = xyMap.mapToIndex(x, y);
275 if (idx < n) {
276 output[idx] = result;
277 }
278 }
279 }
280}
uint32_t x[NUM_LAYERS]
Definition Fire2023.ino:82
uint32_t y[NUM_LAYERS]
Definition Fire2023.ino:83
XYMap xyMap
Definition gfx.cpp:8
uint8_t upscaleFloat(uint8_t v00, uint8_t v10, uint8_t v01, uint8_t v11, float dx, float dy)
Definition upscale.cpp:160
Representation of an RGB pixel (Red, Green, Blue)
Definition crgb.h:55

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

+ Here is the call graph for this function: