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.
4 jobs for colormap in 4 minutes and 34 seconds (queued for 1 second)