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

◆ upscaleArbitraryFloat()

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

Definition at line 181 of file upscale.cpp.

182 {
183 uint16_t n = xyMap.getTotal();
184 uint16_t outputWidth = xyMap.getWidth();
185 uint16_t outputHeight = xyMap.getHeight();
186
187 for (uint16_t y = 0; y < outputHeight; y++) {
188 for (uint16_t x = 0; x < outputWidth; x++) {
189 // Map output pixel to input grid position
190 float fx =
191 static_cast<float>(x) * (inputWidth - 1) / (outputWidth - 1);
192 float fy =
193 static_cast<float>(y) * (inputHeight - 1) / (outputHeight - 1);
194
195 uint16_t ix = static_cast<uint16_t>(fx);
196 uint16_t iy = static_cast<uint16_t>(fy);
197 float dx = fx - ix;
198 float dy = fy - iy;
199
200 uint16_t ix1 = (ix + 1 < inputWidth) ? ix + 1 : ix;
201 uint16_t iy1 = (iy + 1 < inputHeight) ? iy + 1 : iy;
202
203 uint16_t i00 = iy * inputWidth + ix;
204 uint16_t i10 = iy * inputWidth + ix1;
205 uint16_t i01 = iy1 * inputWidth + ix;
206 uint16_t i11 = iy1 * inputWidth + ix1;
207
208 CRGB c00 = input[i00];
209 CRGB c10 = input[i10];
210 CRGB c01 = input[i01];
211 CRGB c11 = input[i11];
212
213 CRGB result;
214 result.r =
215 upscaleFloat(c00.r, c10.r, c01.r, c11.r, dx, dy);
216 result.g =
217 upscaleFloat(c00.g, c10.g, c01.g, c11.g, dx, dy);
218 result.b =
219 upscaleFloat(c00.b, c10.b, c01.b, c11.b, dx, dy);
220
221 uint16_t idx = xyMap.mapToIndex(x, y);
222 if (idx < n) {
223 output[idx] = result;
224 }
225 }
226 }
227}
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.

Referenced by bilinearExpandArbitraryFloat().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: