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

◆ downscale()

void fl::downscale ( const CRGB * src,
const XYMap & srcXY,
CRGB * dst,
const XYMap & dstXY )

Definition at line 154 of file downscale.cpp.

155 {
156 fl::u16 srcWidth = srcXY.getWidth();
157 fl::u16 srcHeight = srcXY.getHeight();
158 fl::u16 dstWidth = dstXY.getWidth();
159 fl::u16 dstHeight = dstXY.getHeight();
160
161 FASTLED_ASSERT(dstWidth <= srcWidth,
162 "Destination width must be <= source width");
163 FASTLED_ASSERT(dstHeight <= srcHeight,
164 "Destination height must be <= source height");
165 const bool destination_is_half_of_source =
166 (dstWidth * 2 == srcWidth) && (dstHeight * 2 == srcHeight);
167 // Attempt to use the downscaleHalf function if the destination is half the
168 // size of the source.
169 if (destination_is_half_of_source) {
170 const bool both_rectangles = (srcXY.getType() == XYMap::kLineByLine) &&
171 (dstXY.getType() == XYMap::kLineByLine);
172 if (both_rectangles) {
173 // If both source and destination are rectangular, we can use the
174 // optimized version
175 downscaleHalf(src, srcWidth, srcHeight, dst);
176 } else {
177 // Otherwise, we need to use the mapped version
178 downscaleHalf(src, srcXY, dst, dstXY);
179 }
180 return;
181 }
182
183 downscaleArbitrary(src, srcXY, dst, dstXY);
184}
XyMapType getType() const
Definition xymap.cpp:128
u16 getWidth() const
Definition xymap.cpp:122
@ kLineByLine
Definition xymap.h:47
u16 getHeight() const
Definition xymap.cpp:124
void downscaleArbitrary(const CRGB *src, const XYMap &srcXY, CRGB *dst, const XYMap &dstXY)
Definition downscale.cpp:82
void downscaleHalf(const CRGB *src, fl::u16 srcWidth, fl::u16 srcHeight, CRGB *dst)
Definition downscale.cpp:18

References downscaleArbitrary(), downscaleHalf(), fl::XYMap::getHeight(), fl::XYMap::getType(), fl::XYMap::getWidth(), and fl::XYMap::kLineByLine.

Referenced by CRGB::downscale(), and loop().

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