Put the switch statement outside of loop

The switch statement is inside of the loop but it always resolves to same case.
Put it outside to optimize the code.
When the case is of one specific color, the other colors is always zero and makes no changes to final result.
So, remove the unnecessary code.
3 jobs for colormap in 4 minutes and 31 seconds (queued for 1 second)
latest
Status Job ID Name Coverage
  Docker Image
passed #278653
debian-testing

00:00:41

 
  Build And Test
passed #278654
autotools-build-and-test

00:03:50

passed #278655
meson-build-and-test

00:01:12