Are there really shifts and masks for 32bpp?

And since you're using it, then you could safely drop if() at all, since those supposed to work for all color formats.