This exact mask-and-invert pattern is how libraries like libjpeg-turbo and OpenCV apply per-pixel color transforms fast enough for real-time video, and it's why a 4K video filter can hit 60 FPS instead of stuttering at a few frames per second on scalar code. The alpha-preservation trick, using an AND/OR mask instead of touching every byte, is the standard technique real image libraries use whenever an operation must skip specific channels.