| 338 | } // namespace |
| 339 | |
| 340 | CRGB ColorFromPaletteExtended(const CRGBPalette32 &pal, fl::u16 index, |
| 341 | fl::u8 brightness, TBlendType blendType) { |
| 342 | // Extract the five most significant bits of the index as a palette index. |
| 343 | fl::u8 index_5bit = (index >> 11); |
| 344 | // Calculate the 8-bit offset from the palette index. |
| 345 | fl::u8 offset = (fl::u8)(index >> 3); |
| 346 | // Get the palette entry from the 5-bit index |
| 347 | const CRGB *entry = &(pal[0]) + index_5bit; |
| 348 | fl::u8 red1 = entry->red; |
| 349 | fl::u8 green1 = entry->green; |
| 350 | fl::u8 blue1 = entry->blue; |
| 351 | |
| 352 | fl::u8 blend = offset && (blendType != NOBLEND); |
| 353 | if (blend) { |
| 354 | if (index_5bit == 31) { |
| 355 | entry = &(pal[0]); |
| 356 | } else { |
| 357 | entry++; |
| 358 | } |
| 359 | |
| 360 | // Calculate the scaling factor and scaled values for the lower palette |
| 361 | // value. |
| 362 | fl::u8 f1 = 255 - offset; |
| 363 | red1 = scale8_LEAVING_R1_DIRTY(red1, f1); |
| 364 | green1 = scale8_LEAVING_R1_DIRTY(green1, f1); |
| 365 | blue1 = scale8_LEAVING_R1_DIRTY(blue1, f1); |
| 366 | |
| 367 | // Calculate the scaled values for the neighbouring palette value. |
| 368 | fl::u8 red2 = entry->red; |
| 369 | fl::u8 green2 = entry->green; |
| 370 | fl::u8 blue2 = entry->blue; |
| 371 | red2 = scale8_LEAVING_R1_DIRTY(red2, offset); |
| 372 | green2 = scale8_LEAVING_R1_DIRTY(green2, offset); |
| 373 | blue2 = scale8_LEAVING_R1_DIRTY(blue2, offset); |
| 374 | cleanup_R1(); |
| 375 | |
| 376 | // These sums can't overflow, so no qadd8 needed. |
| 377 | red1 += red2; |
| 378 | green1 += green2; |
| 379 | blue1 += blue2; |
| 380 | } |
| 381 | if (brightness != 255) { |
| 382 | // nscale8x3_video(red1, green1, blue1, brightness); |
| 383 | nscale8x3(red1, green1, blue1, brightness); |
| 384 | } |
| 385 | return CRGB(red1, green1, blue1); |
| 386 | } |
| 387 | |
| 388 | CRGB16 ColorFromPaletteHD(const CRGBPalette32 &pal, fl::u16 index, |
| 389 | fl::u8x8 brightness, TBlendType blendType) { |
no test coverage detected