BrunniLe 10/02/2024 à 23:58
You can get almost the same by copying the MSB of each component to the LSB. Meaning you can get away with just an AND and a shift, and no branching.
Also, for this format of colors, a table would also work, it'd take just 8 kB.