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 153 of file downscale.cpp.

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

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

Referenced by CRGB::downscale().

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