| 57 | } |
| 58 | |
| 59 | CRGB CRGB::blendAlphaMaxChannel(const CRGB &upper, const CRGB &lower) { |
| 60 | // Use luma of upper pixel as alpha (0..255) |
| 61 | fl::u8 max_component = 0; |
| 62 | for (int i = 0; i < 3; ++i) { |
| 63 | if (upper.raw[i] > max_component) { |
| 64 | max_component = upper.raw[i]; |
| 65 | } |
| 66 | } |
| 67 | // uint8_t alpha = upper.getLuma(); |
| 68 | // blend(lower, upper, alpha) → (lower * (255−alpha) + upper * alpha) / 256 |
| 69 | fl::u8 amountOf2 = 255 - max_component; |
| 70 | return CRGB::blend(upper, lower, amountOf2); |
| 71 | } |
| 72 | |
| 73 | void CRGB::downscale(const CRGB *src, const fl::XYMap &srcXY, CRGB *dst, |
| 74 | const fl::XYMap &dstXY) { |