22 fl::u16 dstWidth = srcWidth / 2;
23 fl::u16 dstHeight = srcHeight / 2;
25 for (fl::u16
y = 0;
y < dstHeight; ++
y) {
26 for (fl::u16
x = 0;
x < dstWidth; ++
x) {
32 const CRGB &p00 = src[(srcY)*srcWidth + (srcX)];
33 const CRGB &p10 = src[(srcY)*srcWidth + (srcX + 1)];
34 const CRGB &p01 = src[(srcY + 1) * srcWidth + (srcX)];
35 const CRGB &p11 = src[(srcY + 1) * srcWidth + (srcX + 1)];
39 (p00.r + p10.r + p01.r + p11.r + 2) / 4;
40 fl::u16
g = (p00.g + p10.g + p01.g + p11.g + 2) / 4;
41 fl::u16 b = (p00.b + p10.b + p01.b + p11.b + 2) / 4;
51 fl::u16 dstWidth = dstXY.getWidth();
52 fl::u16 dstHeight = dstXY.getHeight();
54 FASTLED_ASSERT(srcXY.getWidth() == dstXY.getWidth() * 2,
55 "Source width must be double the destination width");
56 FASTLED_ASSERT(srcXY.getHeight() == dstXY.getHeight() * 2,
57 "Source height must be double the destination height");
59 for (fl::u16
y = 0;
y < dstHeight; ++
y) {
60 for (fl::u16
x = 0;
x < dstWidth; ++
x) {
66 const CRGB &p00 = src[srcXY.mapToIndex(srcX, srcY)];
67 const CRGB &p10 = src[srcXY.mapToIndex(srcX + 1, srcY)];
68 const CRGB &p01 = src[srcXY.mapToIndex(srcX, srcY + 1)];
69 const CRGB &p11 = src[srcXY.mapToIndex(srcX + 1, srcY + 1)];
73 (p00.r + p10.r + p01.r + p11.r + 2) / 4;
74 fl::u16
g = (p00.g + p10.g + p01.g + p11.g + 2) / 4;
75 fl::u16 b = (p00.b + p10.b + p01.b + p11.b + 2) / 4;
78 dst[dstXY.mapToIndex(
x,
y)] =
86 const fl::u16 srcWidth = srcXY.getWidth();
87 const fl::u16 srcHeight = srcXY.getHeight();
88 const fl::u16 dstWidth = dstXY.getWidth();
89 const fl::u16 dstHeight = dstXY.getHeight();
91 const fl::u32
FP_ONE = 256;
93 FASTLED_ASSERT(dstWidth <= srcWidth,
94 "Destination width must be <= source width");
95 FASTLED_ASSERT(dstHeight <= srcHeight,
96 "Destination height must be <= source height");
98 for (fl::u16 dy = 0; dy < dstHeight; ++dy) {
100 fl::u32 dstY0 = (dy * srcHeight *
FP_ONE) / dstHeight;
101 fl::u32 dstY1 = ((dy + 1) * srcHeight *
FP_ONE) / dstHeight;
103 for (fl::u16 dx = 0; dx < dstWidth; ++dx) {
104 fl::u32 dstX0 = (dx * srcWidth *
FP_ONE) / dstWidth;
105 fl::u32 dstX1 = ((dx + 1) * srcWidth *
FP_ONE) / dstWidth;
107 fl::u64 rSum = 0, gSum = 0, bSum = 0;
108 fl::u32 totalWeight = 0;
111 fl::u16 srcY_start = dstY0 /
FP_ONE;
114 fl::u16 srcX_start = dstX0 /
FP_ONE;
117 for (fl::u16 sy = srcY_start; sy < srcY_end; ++sy) {
119 fl::u32 sy0 = sy *
FP_ONE;
120 fl::u32 sy1 = (sy + 1) *
FP_ONE;
125 for (fl::u16 sx = srcX_start; sx < srcX_end; ++sx) {
126 fl::u32 sx0 = sx *
FP_ONE;
127 fl::u32 sx1 = (sx + 1) *
FP_ONE;
132 fl::u32 weight = (x_overlap * y_overlap + (
FP_ONE >> 1)) >>
135 const CRGB &p = src[srcXY.mapToIndex(sx, sy)];
136 rSum += p.r * weight;
137 gSum += p.g * weight;
138 bSum += p.b * weight;
139 totalWeight += weight;
145 totalWeight ? (rSum + (totalWeight >> 1)) / totalWeight : 0;
147 totalWeight ? (gSum + (totalWeight >> 1)) / totalWeight : 0;
149 totalWeight ? (bSum + (totalWeight >> 1)) / totalWeight : 0;
151 dst[dstXY.mapToIndex(dx, dy)] =
CRGB(r,
g, b);
158 fl::u16 srcWidth = srcXY.getWidth();
159 fl::u16 srcHeight = srcXY.getHeight();
160 fl::u16 dstWidth = dstXY.getWidth();
161 fl::u16 dstHeight = dstXY.getHeight();
163 FASTLED_ASSERT(dstWidth <= srcWidth,
164 "Destination width must be <= source width");
165 FASTLED_ASSERT(dstHeight <= srcHeight,
166 "Destination height must be <= source height");
167 const bool destination_is_half_of_source =
168 (dstWidth * 2 == srcWidth) && (dstHeight * 2 == srcHeight);
171 if (destination_is_half_of_source) {
174 if (both_rectangles) {