| 303 | |
| 304 | template <fl::u8 PaletteBits, typename Reader> |
| 305 | CRGB16 ColorFromPaletteHDImpl(const Reader &reader, fl::u16 index, |
| 306 | fl::u8x8 brightness, |
| 307 | TBlendType blendType) { |
| 308 | const fl::u8 frac_bits = 16 - PaletteBits; |
| 309 | const fl::u8 palette_last = (fl::u8(1) << PaletteBits) - 1; |
| 310 | const fl::u32 segment_size = fl::u32(1) << frac_bits; |
| 311 | const fl::u8 entry_index = static_cast<fl::u8>(index >> frac_bits); |
| 312 | const fl::u16 frac = |
| 313 | static_cast<fl::u16>(index & (segment_size - fl::u32(1))); |
| 314 | |
| 315 | const CRGB rgb1 = reader.read(entry_index); |
| 316 | CRGB16 out; |
| 317 | if (frac && blendType != NOBLEND) { |
| 318 | CRGB rgb2; |
| 319 | if (entry_index == palette_last) { |
| 320 | rgb2 = blendType == LINEARBLEND_NOWRAP ? rgb1 : reader.read(0); |
| 321 | } else { |
| 322 | rgb2 = reader.read(entry_index + 1); |
| 323 | } |
| 324 | out = CRGB16(u8x8::from_raw(lerp_channel_to_hd( |
| 325 | rgb1.red, rgb2.red, frac, segment_size)), |
| 326 | u8x8::from_raw(lerp_channel_to_hd( |
| 327 | rgb1.green, rgb2.green, frac, segment_size)), |
| 328 | u8x8::from_raw(lerp_channel_to_hd( |
| 329 | rgb1.blue, rgb2.blue, frac, segment_size))); |
| 330 | } else { |
| 331 | out = promote_rgb_to_hd(rgb1); |
| 332 | } |
| 333 | |
| 334 | scale_rgb_hd(out, brightness); |
| 335 | return out; |
| 336 | } |
| 337 | |
| 338 | } // namespace |
| 339 |
nothing calls this directly
no test coverage detected