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

◆ expand()

void fl::ScaleUp::expand ( fl::span< const CRGB > input,
fl::span< CRGB > output,
u16 width,
u16 height,
const XYMap & mXyMap )

Expand a low-resolution buffer to high-resolution using bilinear interpolation.

Performs bilinear filtering to smoothly upscale pixel data from a source buffer to a destination buffer. Each output pixel is calculated by interpolating the four nearest input pixels, creating smooth transitions and reducing blocky artifacts.

The actual interpolation algorithm used depends on the FASTLED_SCALE_UP compile-time setting:

  • POWER_OF_2: Fast bit-shift version (requires power-of-2 dimensions)
  • HIGH_PRECISION: Integer math for arbitrary dimensions
  • DECIDE_AT_RUNTIME: Automatically selects based on input dimensions
  • FORCE_FLOATING_POINT: Floating-point math (slowest, not recommended)
Note
This method is exposed primarily for unit testing and is not part of the public API. Normal usage should go through draw() which handles buffer management automatically.
Parameters
inputSource buffer containing low-resolution pixel data
outputDestination buffer for high-resolution output (must be pre-allocated)
widthWidth of the low-resolution input buffer
heightHeight of the low-resolution input buffer
mXyMapThe target high-resolution XYMap defining output dimensions and layout

Definition at line 61 of file scale_up.cpp.hpp.

62 {
63#if FASTLED_SCALE_UP == FASTLED_SCALE_UP_ALWAYS_POWER_OF_2
64 fl::upscalePowerOf2(input.data(), output.data(), static_cast<u8>(width), static_cast<u8>(height), mXyMap);
65#elif FASTLED_SCALE_UP == FASTLED_SCALE_UP_HIGH_PRECISION
67#elif FASTLED_SCALE_UP == FASTLED_SCALE_UP_DECIDE_AT_RUNTIME
68 fl::upscale(input.data(), output.data(), width, height, mXyMap);
69#elif FASTLED_SCALE_UP == FASTLED_SCALE_UP_FORCE_FLOATING_POINT
70 fl::upscaleFloat(input.data(), output.data(), static_cast<u8>(width), static_cast<u8>(height), mXyMap);
71#else
72#error "Invalid FASTLED_SCALE_UP"
73#endif
74}
XYMap mXyMap
Definition fx2d.h:30
const T * data() const FL_NOEXCEPT
Definition span.h:461
unsigned char u8
Definition stdint.h:131
u8 u8 height
Definition blur.h:186
void upscaleArbitrary(const CRGB *input, CRGB *output, u16 inputWidth, u16 inputHeight, const XYMap &xyMap)
Performs bilinear interpolation for upscaling an image.
u8 width
Definition blur.h:186
u8 upscaleFloat(u8 v00, u8 v10, u8 v01, u8 v11, float dx, float dy)
void upscale(const CRGB *input, CRGB *output, u16 inputWidth, u16 inputHeight, const fl::XYMap &xyMap)
Definition upscale.h:56
void upscalePowerOf2(const CRGB *input, CRGB *output, u8 inputWidth, u8 inputHeight, const XYMap &xyMap)
Performs bilinear interpolation for upscaling an image.

References fl::span< T, Extent >::data(), fl::height, fl::Fx2d::mXyMap, fl::upscale(), fl::upscaleArbitrary(), fl::upscaleFloat(), fl::upscalePowerOf2(), and fl::width.

Referenced by draw().

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