MCPcopy Create free account
hub / github.com/FastLED/FastLED / downscale

Function downscale

src/fl/gfx/downscale.cpp.hpp:155–185  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 3

downscaleMethod · 0.85
downscale.cppFile · 0.85
loopFunction · 0.85

Calls 5

downscaleHalfFunction · 0.85
downscaleArbitraryFunction · 0.85
getWidthMethod · 0.45
getHeightMethod · 0.45
getTypeMethod · 0.45

Tested by

no test coverage detected