18 {
19 uint16_t dstWidth = srcWidth / 2;
20 uint16_t dstHeight = srcHeight / 2;
21
22 for (uint16_t
y = 0;
y < dstHeight; ++
y) {
23 for (uint16_t
x = 0;
x < dstWidth; ++
x) {
24
25 uint16_t srcX =
x * 2;
26 uint16_t srcY =
y * 2;
27
28
29 const CRGB &p00 = src[(srcY)*srcWidth + (srcX)];
30 const CRGB &p10 = src[(srcY)*srcWidth + (srcX + 1)];
31 const CRGB &p01 = src[(srcY + 1) * srcWidth + (srcX)];
32 const CRGB &p11 = src[(srcY + 1) * srcWidth + (srcX + 1)];
33
34
35 uint16_t r =
36 (p00.r + p10.r + p01.r + p11.r + 2) / 4;
37 uint16_t g = (p00.g + p10.g + p01.g + p11.g + 2) / 4;
38 uint16_t b = (p00.b + p10.b + p01.b + p11.b + 2) / 4;
39
40
41 dst[
y * dstWidth +
x] =
CRGB((uint8_t)r, (uint8_t)g, (uint8_t)b);
42 }
43 }
44}
Representation of an RGB pixel (Red, Green, Blue)